예제 #1
0
    void Enemy_Generator(Enemy_Type type)
    {
        switch (type)
        {
        case Enemy_Type.STONE:
            enemy_copy = Instantiate(enemy_p_obj_S, new Vector3(0f, 12f, 0f), transform.rotation);
            script     = enemy_copy.GetComponent <enemy_controller>();

            RANDOM_size      = Random.Range(0, 3);
            RANDOM_pattern   = Random.Range(0, 3);
            script.HARDNESS  = script.SIZE;        // 硬さ、HP
            script.SIZE      = RANDOM_size;        // 大きさ、速度
            script.PATTERN   = RANDOM_pattern;     // 出現位置
            script.rigidbody = enemy_copy.GetComponent <Rigidbody>();
            enemy_list.Add(enemy_copy);
            break;

        case Enemy_Type.METAL:
            enemy_copy = Instantiate(enemy_p_obj_M, new Vector3(0f, 12f, 0f), transform.rotation);
            script     = enemy_copy.GetComponent <enemy_controller>();

            RANDOM_size      = Random.Range(0, 3);
            RANDOM_pattern   = Random.Range(0, 3);
            script.HARDNESS  = script.METAL;       // 硬さ、HP
            script.SIZE      = RANDOM_size;        // 大きさ、速度
            script.PATTERN   = RANDOM_pattern;     // 出現位置
            script.rigidbody = enemy_copy.GetComponent <Rigidbody>();
            enemy_list.Add(enemy_copy);
            break;
        }
    }
예제 #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (enemy)
        {
            if (col.gameObject.tag == "player")
            {
                player_controller pc = col.GetComponent <player_controller>();
                pc.health = pc.health - dmg;
                Destroy(gameObject);
            }

            else if (col.gameObject.tag != "enemy" & col.gameObject.tag != "bullet")
            {
                Destroy(gameObject);
            }
        }

        else if (hackedenemy)
        {
            if (col.gameObject.tag == "enemy")
            {
                enemy_controller ec = col.GetComponent <enemy_controller>();
                ec.health = ec.health - dmg;
                Destroy(gameObject);
            }

            if (col.gameObject.tag == "player")
            {
                player_controller pc = col.GetComponent <player_controller>();
                pc.health = pc.health - dmg;
                Destroy(gameObject);
            }

            if (col.gameObject.tag == "wall")
            {
                Destroy(gameObject);
            }
        }

        else
        {
            if (col.gameObject.tag != "player")
            {
                if (col.gameObject.tag == "enemy")
                {
                    enemy_controller ec = col.GetComponent <enemy_controller>();
                    ec.health = ec.health - dmg;
                }
                Destroy(gameObject);

                if (col.gameObject.tag == "mainSwitch")
                {
                    switchMain_controller sMc = col.GetComponent <switchMain_controller>();
                    sMc.health = sMc.health - dmg;
                }
            }
        }
    }
예제 #3
0
 public void SetAttackOrder(GameObject enemy)
 {
     attack_target = enemy.GetComponent <enemy_controller>();
     //move to the enemy minus the attack range and a percentage
     move_Script.MoveTo(enemy.transform.position, GetAttackRange() / 100.0f - (GetAttackRange() / 100.0f) * 0.10f);
     //rotate towards the target
     transform.rotation    = Quaternion.LookRotation(new Vector3(attack_target.GetPosition().x, transform.position.y, attack_target.GetPosition().z));
     transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
 }
예제 #4
0
 public void SetOwner(GameObject owner)
 {
     this.owner = owner;
     if ((enemy_handle = owner.GetComponent <enemy_controller>()) != null)
     {
         on_enemy = true;
         enemy_handle.RegisterBuff(this);
         return;
     }
     on_enemy    = false;
     unit_handle = owner.GetComponent <unit_control_script>();
     unit_handle.RegisterBuff(this);
 }
예제 #5
0
 public virtual void SetParentUnit(GameObject parent_unit)
 {
     this.parent_unit = parent_unit;
     //decide whther we are on an enemy or a player
     if (parent_unit.GetComponent <unit_control_script>() == null)
     {
         on_enemy             = true;
         enemy_control_handle = parent_unit.GetComponent <enemy_controller>();
     }
     else
     {
         on_enemy            = false;
         unit_control_handle = parent_unit.GetComponent <unit_control_script>();
     }
 }
	// Use this for initialization
	void Start () {
        Debug.Log(PlayerPrefs.GetInt("Player1"));
        Debug.Log(PlayerPrefs.GetInt("Player2"));
        Player1_Index = PlayerPrefs.GetInt("Player1");
        Player2_Index = PlayerPrefs.GetInt("Player2");
        if (Player1_Index == 0)
        {
            Debug.Log("p0");
            Player1_G.SetActive(true);
            Player1_S.SetActive(false);
        }
        else if (Player1_Index == 1)
        {
            Debug.Log("p1");
            Player1_S.SetActive(true);
            Player1_G.SetActive(false);
        }
        if (Player2_Index == 0)
        {
            Player2_G.SetActive(true);
            Player2_S.SetActive(false);
        }
        else if (Player2_Index == 1)
        {
            Player2_S.SetActive(true);
            Player2_G.SetActive(false);
        }
        Player1 = GameObject.Find("player1");
        Player1_Script = Player1.GetComponent<player1controller>();
        Enemy = GameObject.Find("player2");
        Enemy_Script = Enemy.GetComponent<enemy_controller>();
        Current_Phase = "Ready";
        Feedback.text = "Ready";
        countdown = 4;
        Remain_Time = 99;
        delay = 1;
        Player1_Script.controlable = false;
        Enemy_Script.controlable = false;
        track_player1 = GameObject.Find("player1");
        track_player2 = GameObject.Find("player2");
	}
예제 #7
0
    private void attemptAbilityFire(int index)
    {
        Ability ability = main_unit.GetComponent <unit_control_script>().GetAbility(index);

        if (ability.GetLevel() < 1)
        {
            return;
        }
        if (main_unit.GetMana() < ability.GetCost() || ability.OnCooldown())
        {
            return;
        }
        //if the ability is a point target spell see if there is a target under neath the player and that the enemy is in range
        if (ability.ActivationType == AbilityActivationType.Cast)
        {
            if (ability._TargetType == TargetType.PointTarget)
            {
                //see if there is an enemy under the player cursor
                RaycastHit hit;
                if (Physics.Raycast(GameObject.FindObjectOfType <Camera>().ScreenPointToRay(Input.mousePosition), out hit))
                {
                    enemy_controller enemy = hit.transform.gameObject.GetComponent <enemy_controller>();
                    if (hit.transform.CompareTag("Enemy") && UtilityHelper.InRange(main_unit.GetPosition(), enemy.GetPosition(), (ability.GetCastRange() + main_unit.GetCastRange()) / 100.0f))
                    {
                        ability.ActivateAbility(hit.transform.gameObject);
                        //reduce the players mana
                        main_unit.AddMana(-ability.GetCost());
                    }
                }
            }

            if (ability._TargetType == TargetType.Self)
            {
                //check to see if ability is on cooldown
                if (!ability.OnCooldown())
                {
                    ability.ActivateAbility();
                }
            }
        }
    }
예제 #8
0
    public void Damage(float amount, enemy_controller attacker)
    {
        if (is_dead || physical_damage_immune || damage_immune)
        {
            return;
        }
        //go through all of the effects
        float fixed_damage = amount;

        fixed_damage = fixed_damage * 1 - ((0.06f * GetArmor()) / (1 + 0.06f * Mathf.Abs(GetArmor())));
        foreach (OnHit effect in on_hit_list)
        {
            effect.OnHit(ref fixed_damage, attacker.gameObject);
        }
        //make the particle system activate
        bleed_system.Play();
        hp -= fixed_damage;
        if (attack_target == null || attack_target.IsDead())
        {
            SetAttackOrder(attacker.gameObject);
        }
    }
	void OnTriggerEnter2D (Collider2D ob)
	{
        if (ob.tag == "Enemy")
        {
            enemy = ob.GetComponentInParent<enemy_controller>();
            enemy.HP -= ATK;
            enemy.player_a.SetBool("Hit", true);
            enemy.controlable = false;

        }
        else if (ob.tag == "snowman")
        {
            snowman = ob.GetComponentInParent<special_snowman>();
            snowman.HP -= ATK;
            snowman.player_a.SetBool("Hit", true);
            snowman.controlable = false;

        }
        else if (ob.tag == "Player2")
        {
            player2 = ob.GetComponentInParent<player2controller>();
            player2.HP -= ATK;
            player2.player_a.SetBool("Hit", true);
            player2.controlable = false;

        }
	}
예제 #10
0
 public void RemoveEnemy(enemy_controller enemy)
 {
     enemys.Remove(enemy);
 }
예제 #11
0
 public void AddEnemy(enemy_controller enemy)
 {
     enemys.Add(enemy);
 }