95 lines
1.7 KiB
C#
95 lines
1.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Roy.ObjectPool;
|
|
using SGame;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class KongLogic : MonoBehaviour
|
|
{
|
|
public Image lockIcon;
|
|
private ScrewsLogic screwsLogic;
|
|
|
|
private void Awake()
|
|
{
|
|
lockIcon.gameObject.SetActive(false);
|
|
}
|
|
|
|
public bool IsUsed()
|
|
{
|
|
return screwsLogic != null;
|
|
}
|
|
|
|
public bool CanUse()
|
|
{
|
|
return !IsUsed() && !IsLock();
|
|
}
|
|
|
|
public bool IsSameType(int t)
|
|
{
|
|
if (IsUsed())
|
|
{
|
|
return screwsLogic.screwsType == t;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public void SetCurScrews(ScrewsLogic screws)
|
|
{
|
|
screwsLogic = screws;
|
|
}
|
|
|
|
private void CleanScrews()
|
|
{
|
|
screwsLogic = null;
|
|
}
|
|
|
|
public void MoveScrews(Transform target)
|
|
{
|
|
if (!IsUsed())
|
|
{
|
|
Debug.LogError("逻辑异常请检查!!");
|
|
return;
|
|
}
|
|
CleanScrews();
|
|
}
|
|
|
|
public ScrewsLogic PutScrew(bool isClean = false)
|
|
{
|
|
if (!IsUsed())
|
|
{
|
|
Debug.LogError("逻辑异常请检查!!");
|
|
return null;
|
|
}
|
|
|
|
var screw = screwsLogic;
|
|
if (isClean)
|
|
{
|
|
CleanScrews();
|
|
}
|
|
return screw;
|
|
}
|
|
|
|
public void RemoveScrews()
|
|
{
|
|
if (screwsLogic != null)
|
|
{
|
|
PoolManager.Instance.ReturnObject(screwsLogic.objectName, screwsLogic);
|
|
// Destroy(screwsLogic.gameObject);
|
|
CleanScrews();
|
|
}
|
|
}
|
|
|
|
public bool IsLock()
|
|
{
|
|
return lockIcon.gameObject.activeSelf;
|
|
}
|
|
|
|
public void SetLockState(bool state)
|
|
{
|
|
lockIcon.gameObject.SetActive(state);
|
|
}
|
|
}
|