Пример #1
0
        //Called when "collision" is detected between
        //a magnet-shroom and an Enemy e
        //i.e, when the user select the magnet-shroom attack.
        public void applyMagnetForce(ZombieClass e)
        {
            //If it's a metal accessory, we need to remove the “metal” accessory //from e. How? It’s up to you

            //TODO: complete this method.
            e.applyMagnet();
        }
Пример #2
0
        //To separate the responsibilities, the above methods should not
        //be called directly from your code handling user-interaction.
        //Instead, it should be done in this “hub” operation in the control
        //class. Since we are simulating, pass an “int” to represent the plant.
        public void simulateCollisionDetection(int plant)
        {
            //The method gets access to the “enemies” list in GameObjectManager
            //and finds the first Enemy to be the one to collide with.
            //Then, it passes e to one of the functions above.
            if (this.enemies.Count == 0)
            {
                return;
            }

            ZombieClass zombie = enemies[0];

            switch (plant)
            {
            case 1:
                this.doDamage(25, zombie);
                break;

            case 2:
                this.doDamageFromAbove(40, zombie);
                break;

            case 3:
                this.applyMagnetForce(zombie);
                break;
            }
        }
Пример #3
0
 public void AttackMelee_Execute()
 {
     _behaviour = GetComponent <ZombieClass>();
     _pos       = this.transform.position;
     _dir       = _behaviour.myDirection;
     _pos      += _dir * 0.2f; // 0.2적ㅇ면 되냐? 아니면 구해야하냐/
     this.transform.position = _pos;
 }
Пример #4
0
 public void onZombieCollisionPushback(ZombieClass zombieThatCollided)
 {
     s_health -= zombieThatCollided.getZombieAttackPoints();
     // Debug.Log("A Zombie Touched You. Health = " + s_health);
     if (s_health <= 0)
     {
         youAreDead();
     }
 }
Пример #5
0
        void IDeathObserver.Update(ZombieClass subject, ZombieClass newSubject)
        {
            subject.Detach(this);
            enemies.Remove(subject);

            if (newSubject != null)
            {
                newSubject.Attach(this);
                enemies.Add(newSubject);
            }
        }
Пример #6
0
        public string printZombieInfo()
        {
            if (this.enemies.Count == 0)
            {
                return("[]");
            }
            StringBuilder info = new StringBuilder("[");

            for (int x = 0; x < this.enemies.Count - 1; x++)
            {
                ZombieClass zombie = this.enemies[x];
                info.Append(zombie.getInfo() + ", ");
            }

            info.Append(this.enemies[this.enemies.Count - 1].getInfo() + "]");

            return(info.ToString());
        }
Пример #7
0
    float dropRate = 0.25f; //25% chance of dropping

    // Use this for initialization
    void Start()
    {
        if (ScoreManager.roundCount == 0)
        {
            thisZombieClass = new ZombieClass(this.gameObject, ZombieAttack, UnityEngine.Random.Range(ZombieHealthMin, ZombieHealthMax), ZombieSpeed);
        }
        else
        {
            thisZombieClass = new ZombieClass(this.gameObject, ZombieAttack, (UnityEngine.Random.Range(ZombieHealthMin, ZombieHealthMax) + (ScoreManager.roundCount * 1.25f)), ZombieSpeed);
        }
        //Generate random number between 0 and 1
        if (PauseButton.offSFX)
        {
            try
            {
                GetComponent <AudioSource>().Play();
            }
            catch (Exception ex) {
                Debug.Log("No Component Attached");
            }
        }
    }
Пример #8
0
    /*
     * Section 6.13.1 Function Overrides
     *
     * Instantiate a Parent of the ParentClass object.
     *
     */

    private void Start()
    {
        {
            /*
             * Example 6.13.1.1 A Basic Example.
             *
             * Instantiation happens here.
             */

            ParentClass parent = new ParentClass();
            parent.ParentFunction();

            /*           ↑
             * Parent calls on it's function call.
             *           │
             *         ╭─────────────╮
             *         │ ParentClass │
             *         ╰──┬──────────╯
             *            │
             *            ╰───→ParentFunction()┐
             *                    │            │
             *                    ├→FunctionA()┤
             *                    ╰→FunctionB()┴→────┐
             *         ╭────────────╮                ↓
             *         │ ChildClass │           ╔════╧═════════════════╗
             *         ╰──┬─────────╯           ║ChildClass            ║
             *            │                     ║calls the parent's    ║
             *            ╰→ChildFunction()     ║version of FunctionB()║
             *            ┊  │                  ╚════╤═════════════════╝
             *            ┊  ╰→ParentFunction()┐     ↓
             *            ┊       │            │     │
             *            ┊       ├→FunctionA()┤     ↓
             *            ┊       ╰→FunctionB()┴←────┘
             *            ┊  //child class
             *            ╰┈┈┈┈┈┈┈┈new FunctionB()
             *                      │
             *            ┌─────────┴──────────────────┐
             *            │new hides the parent version│
             *            │of the FunctionB() this     │
             *            │version of FunctionB() isn't│
             *            │called by ChildFunction()   │
             *            └────────────────────────────┘
             *
             *           however when we use override the following happens.
             *
             *         ╭────────────╮                     ↓
             *         │ ChildClass │                ╔════╧═════════════════╗
             *         ╰──┬─────────╯                ║ChildClass            ║
             *            │                          ║calls the parent's    ║
             *            ╰─→ChildFunction()         ║version of FunctionB()║
             *            ┊   │                      ╚════╤═════════════════╝
             *            ┊   ╰→ParentFunction()┐         ↓
             *            ┊        │            │         │
             *            ┊        ├→FunctionB()┴←────────┘
             *            ┊╭──────←┴←virtual FunctionA()
             *            ┊│             │            ╔═════════════════════════════╗
             *            ┊↓             └────────────╢ virtual tells FunctionA()   ║
             *            ┊│                          ║ to change what the Parent   ║
             *            ┊↓  //child class           ║ version does if an override ║
             *            ┊╰→ override FunctionA()    ║ version is present in the   ║
             *            ╰┈┈┈┈┈┈┈┈new FunctionB()    ║ child class but is called   ║
             *                                        ║ when the parent version     ║
             *                                        ║ is called.                  ║
             *                                        ╚═════════════════════════════╝
             */
            ChildClass child = new ChildClass();
            child.ChildFunction();

            /*         ↑                             *
            * The child calls the ChildFunction()   *
            * which skips the child's version of    *
            * FunctionB() but does use the child    *
            * version of FunctionA since it's using *
            * override                              */
        }
        {
            /*
             * Section 6.13.2 Class Inheritance
             */
            ZombieClass  zombie  = new ZombieClass();
            VampireClass vampire = new VampireClass();
            // zombie.HitPoints = 10;
            // vampire.HitPoints = 10;

            /* Assignment of HitPoints = 10
             * every time might be redundant.
             * so they've been added to the
             * constructor of BaseMonsterClass
             */
            Debug.Log(zombie.TakeDamage(5));
            Debug.Log(vampire.TakeDamage(5));
        }
        {
            ZombieClass zombie = new ZombieClass();

            /*
             * Section 6.13.3 Object
             * After adding an override
             * for the ToString() function
             * in zombie we can get a custom
             * Debug.Log() function from it.
             */
            Debug.Log(zombie);
            // "I'm a Zombie!"
        }
    }
Пример #9
0
        public void CreateNewZombie(string type)
        {
            ZombieClass zombie = ZombieFactory.CreateZombie(type, this);

            this.enemies.Add(zombie);
        }
Пример #10
0
 public void doDamageFromAbove(int d, ZombieClass e)
 {
     e.TakeDamageFromAbove(d);
 }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     thisZombieClass = new ZombieClass(this.gameObject, 1f, 55f, .5f);
 }