You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.4 KiB
58 lines
1.4 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using AX.MessageSystem; |
|
using System; |
|
using AX.InputSystem; |
|
|
|
public class CloneSundriesHeap : MonoBehaviour |
|
{ |
|
|
|
public GameObject sundriesHeap; |
|
private CloneObjType cloneObjType; |
|
private int number = 0; |
|
// Use this for initialization |
|
void Start() |
|
{ |
|
cloneObjType = CloneObjType.sundriesHeap; |
|
} |
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
|
|
void OnEnable() |
|
{ |
|
MessageDispatcher.AddListener("CLONE_COMMAND", Execute); |
|
} |
|
|
|
void OnDisable() |
|
{ |
|
MessageDispatcher.RemoveListener("CLONE_COMMAND", Execute); |
|
} |
|
|
|
void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("CLONE_COMMAND", Execute); |
|
} |
|
|
|
private void Execute(IMessage obj) |
|
{ |
|
var gameObjID = (long)obj.Sender; |
|
var data = ((CloneCmdArgs)obj.Data); |
|
if (data.cloneObjType == cloneObjType) |
|
{ |
|
var hitPoint = data.hitPos; |
|
|
|
var clonedObj = EntitiesManager.Instance.CreateObj(sundriesHeap, hitPoint, transform, gameObjID); |
|
|
|
Vector3 clonedObjPos = clonedObj.transform.position; |
|
clonedObj.transform.position = new Vector3(clonedObjPos.x, clonedObjPos.y + 0.5f, clonedObjPos.z); |
|
|
|
clonedObj.name = cloneObjType.ToString() + number++; |
|
SelectedObjs.gameObjs.Add(clonedObj); |
|
} |
|
} |
|
}
|
|
|