Esempio n. 1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "PowerPill" && other.gameObject != foundPillGO && !foundPowerPill)
     {
         foundPowerPill = true;
         destPosition   = other.transform.position;
         agent.SetDestination(destPosition);
         foundPill   = other.GetComponent <PowerPill>();
         foundPillGO = other.gameObject;
     }
 }
Esempio n. 2
0
 public void RemovePowerPill(PowerPill aPowerPill)
 {
     for (int i = 0; i < powerPillCells.Count; i++)
     {
         if (powerPillCells[i] == aPowerPill)
         {
             occupiedCells[aPowerPill.cell.row, aPowerPill.cell.column] = false;
             powerPillCells.RemoveAt(i);
             if (powerPillCells.Count <= 0)
             {
                 GameOver();
             }
             return;
         }
     }
 }
Esempio n. 3
0
    private void OnTriggerStay(Collider other)
    {
        if (other.tag == "Monster" && controller.anim.GetBool("attack1") && controller.lastAttack >= controller.attackRate)
        {
            controller.lastAttack = 0f;
            Health monsterHealth = other.GetComponentInParent <Health>();
            monsterHealth.Damage(attackPower);
            Monster curMonster = other.GetComponentInParent <Monster>();
            if (monsterHealth.healthPoints <= 0)
            {
                curMonster.agent.isStopped = true;
                // TODO: use coroutine to attack monster
                heroScore.UpdateScore(curMonster.monsterPoints);
                curMonster.manager.RemoveMonster(curMonster);
                Destroy(curMonster.gameObject);
            }
            else
            {
                if (curMonster.rend == null)
                {
                    return;
                }
                if (monsterHealth.healthPoints == 2)
                {
                    MaterialPropertyBlock props = new MaterialPropertyBlock();
                    props.SetColor("_EColor", Color.yellow);
                    curMonster.rend.SetPropertyBlock(props);
                }
                else
                {
                    MaterialPropertyBlock props = new MaterialPropertyBlock();
                    props.SetColor("_EColor", Color.red);
                    curMonster.rend.SetPropertyBlock(props);
                }
            }
        }

        else if (other.tag == "PowerPill" && (Input.GetButton("Fire2") || Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.R)))
        {
            PowerPill pill = other.GetComponent <PowerPill>();
            if (pill.health.healthPoints < pill.health.maxHealthPoints)
            {
                heroScore.UpdateScore(1);
                other.GetComponent <PowerPill>().Heal(healAmmount);
            }
        }
    }
Esempio n. 4
0
        public ChaseSubAct()
        {
            _finished   = false;
            _tempTimers = new TimerList();

            _ghostScore = 200;

            _tempSprites = new TimedSpriteList();
            _ghosts      = new List <AttractGhost>();

            var justOffScreen = new Vector2(250, 140);

            _ghostEatenTimer = new EggTimer(0.Milliseconds(), () => { });
            _ghostTimer      = new EggTimer(5.Seconds(), async() => await reverseChase());
            _pacTimer        = new EggTimer(5.1f.Seconds(), () => { });

            _powerPillToEat = new PowerPill
            {
                Visible  = false,
                Position = new Vector2(30, justOffScreen.Y - 4)
            };

            _pillLegend = new Pill {
                Position = new Vector2(70, 178)
            };

            _powerPillLegend = new PowerPill {
                Position = new Vector2(66, 182)
            };

            _pacMan = new AttractScenePacMan {
                Direction = Directions.Left
            };

            var blinky = new AttractGhost(GhostNickname.Blinky, Directions.Left);
            var pinky  = new AttractGhost(GhostNickname.Pinky, Directions.Left);
            var inky   = new AttractGhost(GhostNickname.Inky, Directions.Left);
            var clyde  = new AttractGhost(GhostNickname.Clyde, Directions.Left);

            _ghosts.Add(blinky);
            _ghosts.Add(pinky);
            _ghosts.Add(inky);
            _ghosts.Add(clyde);

            var gap = new Vector2(16, 0);

            _pacPositions    = new StartAndEndPos(justOffScreen, new Vector2(30, justOffScreen.Y));
            _pacMan.Position = _pacPositions.Start;

            _ghostPositions = new Dictionary <GhostNickname, StartAndEndPos>();

            var startPos = justOffScreen + new Vector2(50, 0);
            var endPos   = new Vector2(50, justOffScreen.Y);

            blinky.Position = startPos;
            _ghostPositions[blinky.NickName] = new StartAndEndPos(startPos, endPos);

            startPos       = startPos + gap;
            endPos         = endPos + gap;
            pinky.Position = startPos;
            _ghostPositions[pinky.NickName] = new StartAndEndPos(startPos, endPos);

            startPos      = startPos + gap;
            endPos        = endPos + gap;
            inky.Position = startPos;
            _ghostPositions[inky.NickName] = new StartAndEndPos(startPos, endPos);

            startPos       = startPos + gap;
            endPos         = endPos + gap;
            clyde.Position = startPos;
            _ghostPositions[clyde.NickName] = new StartAndEndPos(startPos, endPos);

            _tempTimers.Add(new EggTimer(1.Seconds(), () => _legendVisible = true));
            _tempTimers.Add(new EggTimer(3.Seconds(), () =>
            {
                _powerPillToEat.Visible = true;
                _copyrightVisible       = true;
            }));

            _tempTimers.Add(new EggTimer(4500.Milliseconds(), () =>
            {
                _ghostsChasing = true;
            }));
        }