コード例 #1
0
    public void FlyMoveToTarget(Vector3 worldposition, AnimalType type)
    {
        AnimalView anView = null;

        if (flyPoollist.Count != 0)
        {
            anView = flyPoollist[0];
        }
        else
        {
            anView = Add();
        }

        //change view
        anView.ChangeSpriteByType(type);

        if (anView != null)
        {
            anView.gameObject.transform.position = worldposition;
            anView.gameObject.SetActive(true);
            flyPoollist.Remove(anView);
            flyUseList.Add(anView);

            CustomFly flycom = anView.gameObject.GetComponent <CustomFly>();
            flycom.EndMove    = this.EndMove;
            flycom.SourecePos = worldposition;

            //只能在最上层移动
            Vector3 targetPos = new Vector3(targetTrans.position.x, targetTrans.position.y, -2);
            flycom.Fly(targetPos);
        }
        else
        {
            Debug.LogError("anView is null!");
        }

        //Debug.Log("--world position--x:" + worldposition.x + "--y:" + worldposition.y + "--z:" + worldposition.z);
    }
コード例 #2
0
ファイル: FlyTest.cs プロジェクト: Hengle/Lua
    public void Fly()
    {
        CustomFly FlyCom = gameObject.GetComponent <CustomFly>();

        FlyCom.Fly(TargetTrans.position);
    }