Ejemplo n.º 1
0
        private void handleZombieAttack()
        {
            Zombie zombie = (Zombie)CurrentPlayer;

            // Get the human to attack
            Human human = zombie.getHumanToAttack();

            if (human != null)
            {
                ZombieAttack zombieAttack = zombie.getCombatAttack(this.combatSystem);
                zombieAttack.TargetGameEntity   = human;
                zombieAttack.AttackerGameEntity = zombie;
                MyBoard.MyCombatAttack          = zombieAttack;

                actionIsTriggered = true;
            }

            if (actionIsTriggered)
            {
                actionHasFinished = false;

                // Initialize or reinitialize
                MyBoard.MyCombatAttack.Initialize();

                // Subtract the weapon range from the player's action points
                CurrentPlayer.subtractActionPointsBy(1);
            }
        }
Ejemplo n.º 2
0
 new void Awake()
 {
     base.Awake();
     animator       = transform.FindChild("zombie").GetComponent <Animator>();
     attack         = GetComponent <ZombieAttack>();
     attack.enabled = false;
 }
Ejemplo n.º 3
0
 void Start()
 {
     zombie          = GetComponent <Zombie>();
     zombieHealth    = GetComponent <ZombieHealth>();
     zombieRigidBody = GetComponent <Rigidbody2D>();
     zombieAttack    = GetComponent <ZombieAttack>();
     playerPosition  = GetComponent <PlayerPosition>();
     RandomJump();
 }
Ejemplo n.º 4
0
        public ZombieAttack getCombatAttack(CombatSystem combatSystem)
        {
            if (zombieAttack == null)
            {
                zombieAttack = new ZombieAttack(lhg, combatSystem);
            }

            return(zombieAttack);
        }
Ejemplo n.º 5
0
    void Start()
    {
        deadCheck = (EnemyHealthScript)gameObject.GetComponent("EnemyHealthScript");
        isDead    = deadCheck.isDead;
        GameObject go = GameObject.FindGameObjectWithTag("Player");

        target          = go.transform;
        weaponTransform = transform.Find("attackBox");
        script          = GetComponent <ZombieAttack> ();
    }
Ejemplo n.º 6
0
    protected void Die()
    {
        ZombieMove   move = GetComponent <ZombieMove>();
        ZombieAttack atk  = GetComponent <ZombieAttack>();

        GameModel.GetInstance().zombieList[move.Row].Remove(gameObject);
        move.enabled = false;
        atk.enabled  = false;
        Destroy(gameObject, 3.0f);
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (attackCooldown > 0f)
        {
            attackCooldown -= Time.deltaTime;
        }

        if (target == null)
        {
            target = gameManager.GetNearestZombie(transform.position);
            if (target)
            {
                targetController = target.GetComponent <ZombieAttack>();
            }
            StopShooting();
        }
        else if (Vector3.Distance(target.transform.position, transform.position) > attackRange)
        {
            navAgent.SetDestination(target.transform.position);
        }
        else
        {
            if (navAgent.hasPath)
            {
                navAgent.ResetPath();
            }
            transform.LookAt(target.transform);
            if (attackCooldown <= 0f)
            {
                anim.SetBool("shooting", true);
                muzzleFlash.Play();
                gunSound.Play();

                targetController.TakeDamage(this.damage);
                if (targetController.IsDead())
                {
                    target           = null;
                    targetController = null;
                    StopShooting();
                }
                attackCooldown = AttackCooldownValue;
            }
        }

        anim.SetFloat("speed", navAgent.velocity.sqrMagnitude);
    }
Ejemplo n.º 8
0
    void Start()
    {
        min = 0;
        max = droppedItem.Count;

        dropable = 1;

        attackScript = transform.FindChild("Attack").GetComponent <ZombieAttack>();

        spriteRend = GetComponent <SpriteRenderer>();
        GetComponent <Rigidbody2D>().velocity = Vector3.zero;
        alive = true;
        if (spriteRend.sprite == null)
        {
            spriteRend.sprite = spriteAlive;
        }
    }
    void Awake()
    {
        zombie01Agent  = zombie01.GetComponent <NavMeshAgent> ();
        zombie02Agent  = zombie02.GetComponent <NavMeshAgent> ();
        skeletonAgent  = skeleton.GetComponent <NavMeshAgent> ();
        zombie01Attack = zombie01.GetComponent <ZombieAttack> ();
        zombie02Attack = zombie02.GetComponent <ZombieAttack> ();
        skeletonAttack = skeletonGameObject.GetComponent <SkeletonAttack> ();

        zombie01Speed = 2f;
        zombie02Speed = 2.5f;
        skeletonSpeed = 2f;
        zombie01Rate  = 1f;
        zombie02Rate  = .75f;
        skeletonRate  = 2f;

        InstantiateZombie01(1);
    }
Ejemplo n.º 10
0
    void Attack(Collider2D other)
    {
        Debug.Log(name + " hit " + other.name);

        // get direction to knockback
        float directionRaw = transform.position.x - other.transform.position.x;
        int   direction    = 0;

        if (directionRaw < 0)
        {
            direction = 1;
        }
        else
        {
            direction = -1;
        }

        // perform knockback

        ZController2D otherController = other.GetComponent <ZController2D>();
        ZombieAttack  otherAttack     = other.GetComponent <ZombieAttack>();
        Animator      otherAnim       = other.GetComponent <Animator>();

        otherController.isStunned = true;
        Vector2 knockback = new Vector2();

        knockback.x = direction * playerKnockback;
        knockback.y = playerKnockbackY;
        other.attachedRigidbody.velocity = knockback;
        otherAnim.SetTrigger("Injured");


        // perform other calculations on Zombie side

        otherAttack.ReceiveDamage(playerDamage, playerStunDuration);
    }
 // Start is called before the first frame update
 void Start()
 {
     target   = 0;
     distance = float.MaxValue;
     zombie   = GetComponent <ZombieAttack>();
 }
Ejemplo n.º 12
0
 new void Awake() {
     base.Awake();
     animator = transform.FindChild("zombie").GetComponent<Animator>();
     attack = GetComponent<ZombieAttack>();
     attack.enabled = false;
 }
Ejemplo n.º 13
0
 // Start is called before the first frame update
 void Start()
 {
     zombieHealth = GetComponent <ZombieAttack>();
 }
Ejemplo n.º 14
0
 protected override void Start()
 {
     base.Start();
     zombieAttack = GetComponentInChildren <ZombieAttack>();
     zombieTimer  = 0f;
 }
Ejemplo n.º 15
0
 public ZombieInfo(GameObject zombie)
 {
     movement = zombie.GetComponent <ZombieMovement>();
     attack   = zombie.GetComponent <ZombieAttack>();
 }
Ejemplo n.º 16
0
 void Awake()
 {
     playerAttack = GetComponent <ZombieAttack>();
     anim         = GetComponent <Animator>();
     navAgent     = GetComponent <UnityEngine.AI.NavMeshAgent>();
 }