Exemplo n.º 1
0
Arquivo: Mole.cs Projeto: TBartl/WTLDT
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     if (moleDir == Direction.NORTH)
     {
         SetRotation(0);
     }
     else if (moleDir == Direction.EAST)
     {
         SetRotation(90);
     }
     else if (moleDir == Direction.SOUTH)
     {
         SetRotation(180);
     }
     else
     {
         SetRotation(270);
     }
     if (hillLocations == null)
     {
         hillLocations    = new IntVector2[1];
         hillLocations[1] = pos;
     }
     currentHillIndex = 0;
     curStep          = StepInProcess.Arrived;
     meshGO           = transform.Find("Mole").gameObject;
 }
Exemplo n.º 2
0
Arquivo: Mole.cs Projeto: TBartl/WTLDT
    public override void Move()
    {
        if (!alarmRaised)
        {
            if (curStep == StepInProcess.Arrived)
            {
                //Animate it coming out of hole
                //------------------------------------
                curStep = StepInProcess.Up;
            }
            else if (curStep == StepInProcess.Up)
            {
                //Animate it going into hole
                //----------------------------------

                IntVector2 initialPos = pos;
                currentHillIndex++;
                if (currentHillIndex >= hillLocations.Length)
                {
                    currentHillIndex = 0;
                }
                IntVector2 movePos = hillLocations[currentHillIndex];
                if (movePos != pos)                 //there are more than one mole hill
                {
                    MoveIfAble(movePos);
                    if (pos != initialPos)                     // you moved, so change to arrived
                    {
                        curStep = StepInProcess.Arrived;
                    }
                }
                else                 // there is only one mole hill
                {
                    curStep = StepInProcess.Arrived;
                }
            }
            if (CanSeePlayer(GetDirectionFacing()))
            {
                RaiseAlarm();
            }
        }
    }