コード例 #1
0
 // Use this for initialization
 void Awake()
 {
     gm        = GetComponent <GridMovement>();
     smu       = updater.GetComponent <SimultaneousUpdater>();
     wt        = updater.GetComponent <WorldTimer>();
     pcc       = GetComponent <PlayerCoinController>();
     wcm       = updater.GetComponent <CoinMultiplier>();
     gst       = GetComponentInChildren <GridSpriteTranslate>();
     anim      = body.GetComponent <Animator>();
     anim_head = head.GetComponent <Animator>();
     eac       = GetComponent <EntityAudioController>();
 }
コード例 #2
0
    // Updates the movement compoent of the enemy.
    public void Move()
    {
        bool attacked = false;

        // Start processing.
        state = MoveStates.PROCESSING;


        // Calls attack method. Should return true if everything is cool
        if (_attackMethod != null)
        {
            attacked = _attackMethod();
            if (attacked)
            {
                state = MoveStates.IDLE;                 // DO NOT MOVE IF TRUE
            }
        }

        // Only call movement if the enemy did not attack.
        if (_movMethod != null && attacked == false)
        {
            // Grab movement from the _movMethod
            declaredMovement = _movMethod();

            // Upon exiting, it should either be IDLE or MOVING.
            ProcessState();
        }

        if (state == MoveStates.MOVING)
        {
            GridSpriteTranslate gst = GetComponentInChildren <GridSpriteTranslate>();
            gst.StartTranslation();

            transform.position += (Vector3)declaredMovement;

            gst.SetPosition();
        }

        // LABEL AS FINISHED
        state = MoveStates.FINISHED;
    }