コード例 #1
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        player = GameObject.FindGameObjectWithTag("Player").transform;
        rb     = animator.GetComponent <Rigidbody2D>();
        enemy  = animator.GetComponent <ChargeEnemy>();

        enemy.LookAtPlayer();

        if (player.position.x > rb.position.x)
        {
            target = new Vector2(player.position.x + chargeOffSet, rb.position.y);
        }
        else
        {
            target = new Vector2(player.position.x - chargeOffSet, rb.position.y);
        }

        rdyUpTime = readyUpTime;
    }
コード例 #2
0
    public static Agent NewAgent(AgentType t, Vector3 pos, AgentStartStats stats)
    {
        Agent a;

        switch (t)
        {
        case AgentType.Enemy:
            a = new Enemy(pos, stats);
            break;

        case AgentType.ChargeEnemy:
            a = new ChargeEnemy(pos, stats);
            break;

        default:
            a = null;
            break;
        }
        return(a);
    }
コード例 #3
0
 // Start is called before the first frame update
 void Start()
 {
     enemy = chargeBaker.GetComponent <ChargeEnemy>();
 }