public void TestSetPos(Transform pos = null)
    {
        foreach (var item in enemyState)
        {
            GameObject player = RoleInterface.GetPlayer();
            GameObject enemy  = item.GetGameObject();
            if (pos)
            {
                enemy.transform.position = new Vector3(pos.position.x, pos.position.y, 0);
            }

            Vector3        offset = new Vector3(enemy.GetComponent <BoxCollider2D>().offset.x, enemy.GetComponent <BoxCollider2D>().offset.y, 0f);
            List <Vector3> path   = MapInterface.FindPath(enemy.transform.position + offset, player.transform.position + offset);
            if (path != null)
            {
                if (item.curState._state != States.autoMove)
                {
                    item.SetState(States.autoMove);
                }
                ;
                path.RemoveAt(0);
                item.curState.OnAutoMove(player.GetComponent <Animator>(), path, 0.01f);
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (GameInput.GetMouseBtn(1))
        {
            player = RoleInterface.GetPlayer();
            offset = new Vector3(player.GetComponent <BoxCollider2D>().offset.x, player.GetComponent <BoxCollider2D>().offset.y, 0f);
            target.transform.position = Camera.main.ScreenToWorldPoint(GameInput.GetMousePos());
            List <Vector3> path = MapInterface.FindPath(player.transform.position + offset, target.transform.position);
            if (path != null)
            {
                if (RoleInterface.GetPlayerState() != States.autoMove)
                {
                    RoleInterface.SetPlayerState(States.autoMove);
                }
                path.RemoveAt(0);
                RoleInterface.OnAutoMove(player.GetComponent <Animator>(), path, 0.01f);
            }
        }

        /*if (GameInput.GetKeyDown(KeyCode.R))
         * {
         *  GameManager.instance.roleManager.GetEnemyManager().TestSetPos(target.transform);
         * }
         *
         * if (GameInput.GetKeyDown(KeyCode.F))
         * {
         *  GameManager.instance.roleManager.GetEnemyManager().TestSetPos();
         * }
         *
         * if (GameInput.GetKeyDown(KeyCode.C))
         * {
         *  GameManager.instance.roleManager.GetEnemyManager().CreatEnemy("player");
         * }*/
    }