コード例 #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);
            }
        }
コード例 #2
0
 new void Awake()
 {
     base.Awake();
     animator       = transform.FindChild("zombie").GetComponent <Animator>();
     attack         = GetComponent <ZombieAttack>();
     attack.enabled = false;
 }
コード例 #3
0
 void Start()
 {
     zombie          = GetComponent <Zombie>();
     zombieHealth    = GetComponent <ZombieHealth>();
     zombieRigidBody = GetComponent <Rigidbody2D>();
     zombieAttack    = GetComponent <ZombieAttack>();
     playerPosition  = GetComponent <PlayerPosition>();
     RandomJump();
 }
コード例 #4
0
ファイル: Zombie.cs プロジェクト: thestig999/LunchHourGames
        public ZombieAttack getCombatAttack(CombatSystem combatSystem)
        {
            if (zombieAttack == null)
            {
                zombieAttack = new ZombieAttack(lhg, combatSystem);
            }

            return(zombieAttack);
        }
コード例 #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> ();
    }
コード例 #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);
    }
コード例 #7
0
ファイル: Soldier.cs プロジェクト: CyrilBos/Zombinvasion
    // 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);
    }
コード例 #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;
        }
    }
コード例 #9
0
    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);
    }
コード例 #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);
    }
コード例 #11
0
 // Start is called before the first frame update
 void Start()
 {
     target   = 0;
     distance = float.MaxValue;
     zombie   = GetComponent <ZombieAttack>();
 }
コード例 #12
0
 new void Awake() {
     base.Awake();
     animator = transform.FindChild("zombie").GetComponent<Animator>();
     attack = GetComponent<ZombieAttack>();
     attack.enabled = false;
 }
コード例 #13
0
 // Start is called before the first frame update
 void Start()
 {
     zombieHealth = GetComponent <ZombieAttack>();
 }
コード例 #14
0
 protected override void Start()
 {
     base.Start();
     zombieAttack = GetComponentInChildren <ZombieAttack>();
     zombieTimer  = 0f;
 }
コード例 #15
0
 public ZombieInfo(GameObject zombie)
 {
     movement = zombie.GetComponent <ZombieMovement>();
     attack   = zombie.GetComponent <ZombieAttack>();
 }
コード例 #16
0
 void Awake()
 {
     playerAttack = GetComponent <ZombieAttack>();
     anim         = GetComponent <Animator>();
     navAgent     = GetComponent <UnityEngine.AI.NavMeshAgent>();
 }