Inheritance: MonoBehaviour
 /// <summary>
 /// Initializes a new instance of the <see cref="SwiftDeathDebuff"/> class.
 /// </summary>
 /// <param name='enemy'>
 /// Enemy afflicted by the SwiftDeathDebuff.
 /// </param>
 public SwiftDeathDebuff(EnemyScript enemy)
 {
     this.enemy = enemy;
     texture = Resources.Load("Debuffs/SwiftDeath") as Texture2D;
     expirationTime = Time.time + duration;
     damage = (GameObject.FindGameObjectWithTag("Player").GetComponent(typeof(PlayerScript)) as PlayerScript).WeaponDamage;
 }
Example #2
0
	private void Init(){
		this.gameManager = GameObject.Find ("GameManager").GetComponent<GameManager> ();
		this.player = GameObject.Find ("Player").GetComponent<PlayerScript> ();
		this.enemy = GameObject.Find ("Enemy").GetComponent<EnemyScript> ();
		this.mPlayerShieldHP = Constants.ShieldPoint;
		this.mEnemyShieldHP = Constants.ShieldPoint;
	}
Example #3
0
 // Use this for initialization
 void Start()
 {
     ds = door.GetComponent<DoorScript>();
     es = boss.GetComponent<EnemyScript>();
     ehs = boss.GetComponent<EnemyHealthScript>();
     ps = VariableScript.scrPlayerScript1;
     speed = es.MoveSpeed;
 }
 public void RemoveEnemy( EnemyScript enemy )
 {
     bool isLeft = enemy == nearestLeftEnemy;
     List<EnemyScript> list = isLeft ? leftEnemies : rightEnemies;
     list.Remove( enemy );
     if ( isLeft ) nearestLeftEnemy = findNearestEnemy( list );
     else nearestRightEnemy = findNearestEnemy( list );
 }
Example #5
0
 private void Start()
 {
     myMat = GetComponent<Renderer>().material;
     fishVehicles = Pond.Instance.GetEntitiesOfType(EntityType.Fish).Select(entity => entity.GetComponent<Vehicle>()).ToArray();
     theEnemy = EnemyScript.Me;
     DetectDamageEnemy();
     SfxManager.Instance.PlaySound(SfxManager.Instance.RippleSound,1f,Random.Range (0.7f,1.8f));
 }
 public void SetTarget(PlayerScript caster, EnemyScript target)
 {
     attackTarget = target;
     playerCaster = caster;
     attackLocation = target.transform.position;
     initialized = true;
     foundTarget = true;
 }
Example #7
0
    void Awake()
    {
        // Retrieve the weapon only once
        weapons = GetComponentsInChildren<WeaponScript>();

        // Retrieve scripts to disable when not spawn
        enemyScript = GetComponent<EnemyScript>();
    }
Example #8
0
    // Use this for initialization
    void Start()
    {
        Boss = GetComponentInParent <EnemyScript > ();
        OldHealth = Boss.BossHealth;

        healthLength = this.gameObject.GetComponent<SpriteRenderer> ().bounds.size .x;
        startPosition = this.gameObject.transform.localPosition .x;
    }
	public void CreateSpider()
	{
		clone = Instantiate(enemy, Input.mousePosition, Quaternion.identity) as GameObject;
		enemyScript = clone.GetComponent<EnemyScript>();
		Transform trans = clone.transform;

		//enemyScript.isSpawning = true;
		
		Slider slider = clone.GetComponentInChildren<Slider>();
		Vector3 sliderScale = slider.transform.localScale;
		Vector3[] scales = new Vector3[]{trans.localScale * 0.7f, trans.localScale,  trans.localScale * 2f};
		float[] startingHealths = new float[]{10f, 100f, 300f};
		float[] speeds = {2f, 1.5f, 1f};
		float[] damages = {5f, 10f, 20f};
		float[] healingRates = {0f, 10f, 30f};
		float[] animSpeeds = {5f, 1.5f, 0.6f};
		int[] points = {1, 2, 5};
		int[] masses = {1, 2, 5};
		float[] stunTimes = {1f, 0.3f, 0.05f};

		int size = 0;

		if (val > scoutCost && val <= soldierCost)
		size = 0;
		else if (val >= soldierCost && val < queenCost)
			size = 1;
		else if (val >= 100)
			size = 2;

		trans.localScale = scales[size];
		slider.transform.localScale = sliderScale;
		enemyScript.startingHealth = startingHealths[size]; 
		
		enemyScript.walkSpeed = speeds[size];
		enemyScript.runSpeed = speeds[size] * 3f;
		clone.GetComponent<AIPath>().speed = speeds[size];
		
		enemyScript.walkAnimSpeed = animSpeeds[size];
		enemyScript.runAnimSpeed = animSpeeds[size];
		
		enemyScript.damage = damages[size];	
		//enemyScript.slider.maxValue = startingHealths[size];
	//	enemyScript.slider.minValue = 0;
	//	enemyScript.slider.value = startingHealths[size];
		enemyScript.currentHealth = startingHealths[size];
		enemyScript.healingRate = healingRates[size];
	//	enemyScript.rigidbody.mass = masses[size];
		enemyScript.stunTime = stunTimes[size];

		clone.collider.enabled = false;
		clone.layer = 2;

		GameObject mesh = enemyScript.mesh;
		Color color = mesh.renderer.material.color;
		color.a = 0.3f;
		mesh.renderer.material.color = new Color(color.r, color.g, color.b, color.a);

	}
Example #10
0
	// Use this for initialization
	void Start () {
		PS = GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerScript> ();
		ES = GameObject.FindGameObjectWithTag ("Enemy").GetComponent<EnemyScript> ();
		NS = GameObject.FindGameObjectWithTag ("Spawner").GetComponent<NoteSpawner> ();
		//NM = GameObject.FindGameObjectWithTag ("Note").GetComponent<NoteMovement> ();
		//MBM = GameObject.FindGameObjectWithTag ("MeasureBar").GetComponent<MeasureBarMovement> ();
		playerDamage.enabled = false;
		enemyDamage.enabled = false;
	}
Example #11
0
    void Start()
    {
        unitControl = GetComponentInParent<EnemyScript>();

        if (particleObj)
            actionFX = particleObj.GetComponent<ParticleSystem>();

        actionAudio = unitControl.GetComponent<AudioSource>();
    }
Example #12
0
 void Awake()
 {
     plane = transform.FindChild("Plane");
     reticle = transform.FindChild("Reticle");
     es = GetComponent<EnemyScript>();
     if(missileModel == null){
         missileModel = VariableScript.objBullet;
     }
 }
 protected IEnumerator enableFrontEffects( EnemyScript enemy )
 {
     yield return new WaitForEndOfFrame();
     if( enemy == null ) yield break;
     SpriteRenderer[] renderers = enemy.GetComponentsInChildren<SpriteRenderer>();
     foreach( SpriteRenderer renderer in renderers ) {
         renderer.sortingLayerID = FRONT;
         renderer.color = FRONT_COLOR;
     }
 }
Example #14
0
    private void Start()
    {
        navMeshAgent = GetComponent<NavMeshAgent>();
        behaviour = GetComponent<EnemyBehaviour>();
        stats = GetComponent<EnemyScript>();

        navMeshAgent.speed *= speedMultiplier;
        behaviour.attackDamage *= damageMultiplier;
        stats.MaxHealth *= healthMultiplier;
    }
Example #15
0
 void OnTriggerEnter(Collider other)
 {
     //Debug.Log(string.Format("WeaponAcid: OnTriggerEnter: {0}", other));
     if (other.gameObject.tag == "Enemy")
     {
         enemy = other.GetComponent<EnemyScript>();
         enemy.currentSpeed = slow;
         slowedEnemies.Add(other);
     }
 }
Example #16
0
    public void Start()
    {
        enemy = this.GetComponent<EnemyScript>();
        // the name of the enemy
        string name = "NAME:   " + enemy.enemyName;
        // the armor of the enemy
        string armor =  "\nARMOR:   " + enemy.armor;
        // the resistances
        string resistances =  "\nRESISTANCES:";
        for (int i = 0; i < enemy.resistances.Count; i++) {
            resistances = resistances + "   " + enemy.resistances[i];
        }
        if (0 == this.GetComponent<EnemyScript> ().resistances.Count) {
            resistances = resistances + "   None";
        }

        //the specials
        string specials = "\nSPECIALS:";
        int specialCount = 0;
        foreach( Toolbox.EnemySpecial special in enemy.specials){
            if(special == Toolbox.EnemySpecial.Fortified ||
               special == Toolbox.EnemySpecial.Brutal ||
               special == Toolbox.EnemySpecial.Poison ||
               special == Toolbox.EnemySpecial.Swift){
                specialCount++;
                specials += "   " + special.ToString();
            }
        }
        if (specialCount == 0){
            specials += "\nNone";
        }

        //the fame
        string fame = "\nFAME:   " + enemy.fame;

        // the attacks
        string attacks =  "\nATTACKS: ";
        for (int i = 0; i < enemy.attacks.Count; i++) {
            attacks = attacks + "\nType: " + enemy.attacks[i].type;
            attacks = attacks + "   Strength: " + enemy.attacks[i].value;
        }

        toolTipText = name + fame + armor + resistances + specials + attacks;

        // set up
        guiStyleFore = new GUIStyle();
        guiStyleFore.normal.textColor = Color.white;
        guiStyleFore.alignment = TextAnchor.UpperCenter ;
        guiStyleFore.wordWrap = true;
        guiStyleBack = new GUIStyle();
        guiStyleBack.normal.textColor = Color.black;
        guiStyleBack.alignment = TextAnchor.UpperCenter ;
        guiStyleBack.wordWrap = true;
    }
 public EnemyScript SelectHealTarget()
 {
     float lowest = 100.0f;
     for (int i = 0; i < uiScript.enemy.Count; i++)
     {
         if (uiScript.enemy[i].health < lowest)
         {
             lowest = uiScript.enemy[i].health;
             healTarget = uiScript.enemy[i];
         }
     }
     return healTarget;
 }
Example #18
0
 private void Init(){
     this.fadeScript = GameObject.Find("FadePanel").GetComponent<FadeScript>();
     this.player = GameObject.Find("Player").GetComponent<PlayerScript>();
     this.enemy = GameObject.Find("Enemy").GetComponent<EnemyScript>();
     this.startWaitTime = Constants.StartWaitTime;
     this.PlayerShotWaitTime = Constants.ShotWaitTime;
     this.EnemyShotWaitTime = Constants.ShotWaitTime;
     this.mPlayerHP = Constants.MaxLife;
     this.mPlayerShieldHP = Constants.ShieldPoint;
     this.mEnemyHP = Constants.MaxLife;
     this.mEnemyShieldHP = Constants.ShieldPoint;
     this.mPlayerGuardTime = Constants.GuardTime;
     this.mEnemyGuardTime = Constants.GuardTime;
     this.PlayerBallReload();
     this.EnemyBallReload();
 }
    public void updateEnemy(int index)
    {
        EnemyScript enemy = lesEnemies[index];

        if (lesEnemies[index] != null)
        {
            if (!FogManager.getInstance().isFog(enemy.getX(), enemy.getY()))
            {
                lesEnemies[index].actif = true;
                lesEnemies[index].StartActions();
            }
            else
            {
                TurnManager.getInstance().nextEnemy();
            }
        }
        else
        {
            TurnManager.getInstance().nextEnemy();
        }
    }
Example #20
0
    public void HitEnemy(RaycastHit hit)
    {
        Debug.Log("HitEnemy stsart");
        //Destroy(hit.transform.gameObject);
        EnemyScript enemy = hit.transform.gameObject.GetComponent <EnemyScript>();

        if (enemy.enemyState == EnemyScript.EnemyState.dead)
        {
            return;
        }

        Instantiate(hold, transform.position - hit.transform.position + Vector3.forward * hit.distance, transform.localRotation);
        Debug.Log("꺼내옴 : ");
        enemy.enemyState = EnemyScript.EnemyState.damage;
        int layerIndex = enemy.gameObject.layer;

        if (layerIndex != 10)                                          //이것도 같다.
        {
            return;
        }
    }
    EnemyScript ClosestCounterEnemy()
    {
        float minDistance = 100;
        int   finalIndex  = 0;

        for (int i = 0; i < enemyManager.allEnemies.Length; i++)
        {
            EnemyScript enemy = enemyManager.allEnemies[i].enemyScript;

            if (enemy.IsPreparingAttack())
            {
                if (Vector3.Distance(transform.position, enemy.transform.position) < minDistance)
                {
                    minDistance = Vector3.Distance(transform.position, enemy.transform.position);
                    finalIndex  = i;
                }
            }
        }

        return(enemyManager.allEnemies[finalIndex].enemyScript);
    }
Example #22
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        // Collision with enemy
        EnemyScript enemy = collision.gameObject.GetComponent <EnemyScript>();

        if (enemy != null)
        {
            // Kill the enemy
            HealthScript enemyHealth = enemy.GetComponent <HealthScript>();
            if (enemyHealth != null)
            {
                enemyHealth.Damage(enemyHealth.hp);
            }

            HealthScript playerHealth = this.GetComponent <HealthScript>();
            if (playerHealth != null)
            {
                playerHealth.Damage(1);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        lastSpawn += Time.deltaTime;

        if (lastSpawn >= spawnSpeed)
        {
            for (int i = 0; i < poolSize; i++)
            {
                if (enemyPool[i].gameObject.activeSelf == false)
                {
                    EnemyScript enemy = enemyPool[i].GetComponent <EnemyScript>();

                    enemy.initialize();
                    enemyPool[i].transform.position = randomLocationOnScreen();
                    break;
                }
            }

            lastSpawn = 0f;
        }
    }
Example #24
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag == "Zombie")
        {
            EnemyScript  enemy = collision.gameObject.GetComponent <EnemyScript>();
            HealthScript myHp  = GetComponent <HealthScript>();

            myHp.SetHp(myHp.GetHp() - enemy.damage);
            if (myHp.hb != null)
            {
                myHp.hb.SetHealth(myHp.GetHp());
            }
            Destroy(enemy.gameObject);

            if (myHp.GetHp() <= 0)
            {
                Destroy(gameObject);
                FindObjectOfType <GameManager>().EndGame();
            }
        }
    }
Example #25
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (InPowerUp)
        {
            if (other.gameObject.CompareTag("Ghost"))
            {
                //other.gameObject.transform.position = spawnPoint.transform.position;
                enemyController = other.gameObject.GetComponent <EnemyScript>();
                if (enemyController.isFleeing())
                {
                    //scoreManager.addScore(other.gameObject.GetComponent<EnemyScript>().scoreWorth * killCounter);
                    ScoreManager.addScore(other.gameObject.GetComponent <EnemyScript>().scoreWorth *killCounter);
                    killCounter++;
                    enemyController.Eaten();
                }
                agentMovementManager.setAllowToMove(false);

                //Destroy(other.gameObject);
            }
        }
    }
Example #26
0
    public EnemyScript GetLongestShip(List <EnemyScript> list)
    {
        if (list.Count == 0)
        {
            return(null);
        }

        EnemyScript returnee = null;
        float       size     = 0;

        foreach (EnemyScript ship in list)
        {
            if (returnee == null || ship.GetShipHeight() > size)
            {
                returnee = ship;
                size     = ship.GetShipHeight();
            }
        }

        return(returnee);
    }
    // Use this for initialization
    void Start()
    {
        GameObject gameData = GameObject.Find("GameDataObject"); //Get all game objects needed

        player = GameObject.Find("Player");
        enemy  = GameObject.Find("Enemy");

        gameDataScript         = gameData.GetComponent <GameDataScript>();       //This is used to transfer the PK between all scenes
        playerBehavioursScript = player.GetComponent <PlayerBehavioursScript>(); //This is used to allow us to load new data into player and enemy scripts
        enemyScript            = enemy.GetComponent <EnemyScript>();

        dbConnectionString = "URI=file:" + Application.dataPath + "/Database.sqlite"; //filepath

        playerID = gameDataScript.playerKey;


        if (gameDataScript.loaded)
        {
            StartCoroutine("Wait"); //wait so the other objects can fully load (See IEnumerator at bottom of this script)
        }
    }
    IEnumerator Shoot()
    {
        audio_laser = GetComponent <AudioSource>();
        audio_laser.Play();
        RaycastHit2D hitInfo = Physics2D.Raycast(firePoint.position, firePoint.right);

        if (hitInfo)
        {
            Debug.Log(hitInfo.transform.name);
            EnemyScript enemy = hitInfo.transform.GetComponent <EnemyScript>();
            ShotScript  shot  = hitInfo.transform.GetComponent <ShotScript>();
            if (enemy != null)
            {
                HealthScript health = hitInfo.transform.GetComponent <HealthScript>();
                if (health != null)
                {
                    Debug.Log("DIE!!!!");
                    health.Damage(laserDmg);
                }
            }
            else if (shot != null)
            {
                Destroy(shot.gameObject);
            }

            lineRenderer.SetPosition(0, firePoint.position);
            lineRenderer.SetPosition(1, hitInfo.point);
        }
        else
        {
            Debug.Log("No Hit!");
            lineRenderer.SetPosition(0, firePoint.position);
            lineRenderer.SetPosition(1, firePoint.position + firePoint.right * 100);
        }

        lineRenderer.enabled = true;
        yield return(new WaitForSeconds(0.02f));

        lineRenderer.enabled = false;
    }
    //Initialization of values
    void Start()
    {
        //Retrieving references to game objects
        GameObject gameControllerObject = GameObject.FindWithTag("GameController");

        gamePlayerController = GameObject.FindWithTag("Player");

        gameEnemyScript = GameObject.FindWithTag("EnemyShip");

        if (gameControllerObject != null)
        {
            gameController = gameControllerObject.GetComponent <GameController>();
        }
        if (gameController == null)
        {
        }


        if (gamePlayerController != null)
        {
            playerController = gamePlayerController.GetComponent <PlayerController>();
        }
        if (gamePlayerController == null)
        {
        }



        if (gameEnemyScript != null)
        {
            enemyScript = gameEnemyScript.GetComponent <EnemyScript>();
        }
        if (gameEnemyScript == null)
        {
        }
        ScoreValue    = gameController.HazardScore;
        HazardHealth  = gameController.HazardHealth;
        originalColor = gameObject.GetComponent <SpriteRenderer>().color;
        hitColor      = Color.gray;
    }
Example #30
0
    public EnemyScript GetLargestShipInGroup()
    {
        if (m_shipCount == 0)
        {
            return(null);
        }

        EnemyScript largestShip = null;
        float       size        = 0;

        foreach (List <EnemyScript> list in m_children)
        {
            EnemyScript largestShipInList = GetLargestShip(list);
            if (largestShip == null || largestShipInList.GetMaxSize() > size)
            {
                largestShip = largestShipInList;
                size        = largestShipInList.GetMaxSize();
            }
        }

        return(largestShip);
    }
Example #31
0
    void PlayerMove(int x, int y)
    {
        previousPosition = this.transform.position;

        // check if moving into an enemy
        EnemyScript enemy = (from item in gameManager.gameEntities
                             where item.transform.position.x == transform.position.x + x && item.transform.position.y == transform.position.y + y
                             select item).FirstOrDefault();

        if (enemy == null)
        {
            // do this with an animation or something?
            desiredPosition = new Vector2(transform.position.x + x, transform.position.y + y);
        }
        else
        {
            // attack enemy
            playerScript.Attack(enemy.GetComponent <Damageable>());
            desiredPosition = new Vector2(transform.position.x + (float)x / 2, transform.position.y + (float)y / 2);
            attacking       = true;
        }
    }
Example #32
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        print("collide");
        // Is this a shot?
        ShotScript   shot   = otherCollider.gameObject.GetComponent <ShotScript>();
        PlayerScript player = otherCollider.gameObject.GetComponent <PlayerScript>();
        EnemyScript  enemy  = otherCollider.gameObject.GetComponent <EnemyScript>();

        Debug.Log(shot + " " + player + " " + enemy);
        if (shot != null)
        {
            // Avoid friendly fire
            if (shot.isEnemyShot != isEnemy)
            {
                print("shot");
                Damage(shot.damage);

                // Destroy the shot
                Destroy(shot.gameObject); // Remember to always target the game object, otherwise you will just remove the script
            }
        }

        // Is this a player ?
        if (player != null)
        {
            print("player");
            Destroy(this.gameObject);
        }

        // Is this an ennemy ?
        if (enemy != null)
        {
            print("enemy");
            Damage(enemy.damage);

            // Destroy the enemy
            Destroy(enemy.gameObject);
        }
    }
Example #33
0
    private void SpawnEnemies()
    {
        for (int i = 0; i < enemies.Count; i++)
        {
            if (enemies[i] == null)
            {
                // Calculate the position where the enemy is spawned.
                Vector2 enemyPosition2D = Random.insideUnitCircle.normalized * distanceFromPlayer;
                Vector3 enemyPosition   = new Vector3(enemyPosition2D.x, Random.Range(minHeight, maxHeight), enemyPosition2D.y);

                // Spawn the enemy.
                enemies[i] = Instantiate(enemyToSpawn, enemyPosition, player.transform.rotation);

                // Make the enemy face the player.
                enemies[i].transform.LookAt(player.transform.position);

                // Set the properties of the enemy.
                EnemyScript enemyScript = enemies[i].GetComponent <EnemyScript>();
                enemyScript.player = player;
            }
        }
    }
Example #34
0
    public void Hit()
    {
        //애니메이션 이벤트, 충돌 처리 등을 체크
        //여기서 콜리더 히트 체크
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_iRange, 1 << LayerMask.NameToLayer("Enemy"));

        if(colliders.Length != 0)
        {
            int iCurChar = GameManager.instance.ReturnCurPlayer();
            int[] List = GameManager.instance.ReturnPlayerList();
            float fATK = float.Parse(UserInfo.instance.GetCharData(CHAR_DATA.CHAR_ATK, List[iCurChar]).ToString());
            float fCRI = float.Parse(UserInfo.instance.GetCharData(CHAR_DATA.CHAR_CRI, List[iCurChar]).ToString());

            for(int i = 0; i < colliders.Length; i++)
            {
                EnemyScript script = colliders[i].GetComponent<EnemyScript>() ?? null;
                if (script != null)
                    script.Damege(fATK, fCRI);
                //해당 함수 호출
            }      
        }
    }
Example #35
0
    IEnumerator Shoot()
    {
        RaycastHit2D HitInfo = Physics2D.Raycast(FirePoint.position, (testV - FirePoint.position), 100f);

        Debug.DrawRay(FirePoint.position, (testV - FirePoint.position), Color.red);

        if (HitInfo)
        {
            line.SetPosition(0, FirePoint.position);
            line.SetPosition(1, testV);
            EnemyScript EnemyScript = HitInfo.transform.GetComponent <EnemyScript>();
            if (EnemyScript != null)
            {
                EnemyScript.TakeDamage(DamagePerShot);
            }
        }
        else
        {
            line.SetPosition(0, FirePoint.position);
            line.SetPosition(1, testV);
        }
        if (HitInfo)
        {
            if (HitInfo.transform.tag == "Destructable")
            {
                Debug.Log("Hit");
                BridgeControl damagable = HitInfo.transform.GetComponent <BridgeControl>();
                damagable.DamageTaken();
            }
        }
        line.enabled = true;
        yield return(new WaitForSeconds(0.02f));

        line.enabled = false;
        //if (HitInfo)
        //{
        //    Debug.Log(HitInfo.transform.name);
        //}
    }
	void OnCollisionEnter2D(Collision2D collision)
	{
		bool damagePlayer = false;
		
		// Collision with enemy
		EnemyScript enemy = collision.gameObject.GetComponent<EnemyScript>();
		if (enemy != null)
		{
			// Kill the enemy
			HealthScript enemyHealth = enemy.GetComponent<HealthScript>();
			if (enemyHealth != null) enemyHealth.Damage(enemyHealth.hp);
			
			damagePlayer = true;
		}
		
		// Damage the player
		if (damagePlayer)
		{
			HealthScript playerHealth = this.GetComponent<HealthScript>();
			if (playerHealth != null) playerHealth.Damage(1);
		}
	}
Example #37
0
 void RotateEnemies()
 {
     if (Input.GetAxisRaw("rot_" + (playerTag.Id).ToString()) != 0f && lastAxis == 0f)
     {
         for (int i = 0; i < enemy_count; i++)
         {
             if (enemies_active [i] != null)
             {
                 EnemyScript enemy_script = enemies_active [i].GetComponent <EnemyScript> ();
                 enemy_script.side = (int)(((float)enemy_script.side + Input.GetAxisRaw("rot_" + (playerTag.Id).ToString())) % enemies_active.Length);
                 float angle = (360f / enemies_active.Length) * enemy_script.side;
                 enemy_script.sideVec = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle)) * 2f;
             }
         }
         GameObject temp = enemies_active [0];
         for (int i = 0; i < enemies_active.Length; i++)
         {
             enemies_active [i] = enemies_active[(i + 1) % enemies_active.Length];
         }
         enemies_active [enemies_active.Length - 1] = temp;
     }
 }
Example #38
0
 // Use this for initialization
 void Start()
 {
     anim          = GetComponent <Animator>();
     myRigidbody2D = GetComponent <Rigidbody2D>();
     //hitPoints = 10;
     try
     {
         player = GameObject.FindGameObjectWithTag("Player").transform;
     }
     catch (UnityException e)
     {
         if (e.GetType().Equals("NullReferenceException"))
         {
             Debug.LogWarning(e.Message);
             player = null;
         }
     }
     myScript       = GetComponent <EnemyScript>();
     speed          = myScript.speed;
     atkRange       = myScript.atkRange;
     detectionRange = myScript.detectionRange;
 }
Example #39
0
    //reduce the effect
    public override void actualDamage(ref DamageEventData d)
    {
        EnemyScript enemy = d.dest;

        if (enemy.effectData != null)
        {
            foreach (IEffect curEffect in enemy.effectData.effects)
            {
                //drill down through meta effects also, if they are present
                IEffect finalCurEffect = curEffect;
                while (finalCurEffect.XMLName != argument && finalCurEffect.triggersAs(EffectType.meta)) //keep descending until we find the effect we are looking for or this is not a meta effect
                {
                    finalCurEffect = ((IEffectMeta)finalCurEffect).innerEffect;
                }

                if (finalCurEffect.XMLName == argument)
                {
                    finalCurEffect.strength = Mathf.Max(0, finalCurEffect.strength - strength);
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        timerUntilNewCreation += Time.deltaTime;
        if (timerUntilNewCreation > 1)
        {
            timerUntilNewCreation = 0;

            // Création d'un objet copie du prefab
            Transform enemiTransform = Instantiate(enemiPrefab) as Transform;

            var leftBorder   = CameraHelper.Left;
            var rightBorder  = CameraHelper.Right;
            var bottomBorder = CameraHelper.Bottom;

            //Une position aléatoire
            float positionAxeX = Random.Range(rightBorder, leftBorder);
            enemiTransform.position = new Vector3(positionAxeX, bottomBorder * 1.5f);

            // Propriétés du script
            EnemyScript enemy = enemiTransform.gameObject.GetComponent <EnemyScript>();
        }
    }
    void CounterCheck()
    {
        //Initial check
        if (isCountering || isAttackingEnemy || !enemyManager.AnEnemyIsPreparingAttack())
        {
            return;
        }

        lockedTarget = ClosestCounterEnemy();
        OnCounterAttack.Invoke(lockedTarget);

        if (TargetDistance(lockedTarget) > 2)
        {
            Attack(lockedTarget, TargetDistance(lockedTarget));
            return;
        }

        float duration = .2f;

        animator.SetTrigger("Dodge");
        transform.DOLookAt(lockedTarget.transform.position, .2f);
        transform.DOMove(transform.position + lockedTarget.transform.forward, duration);

        if (counterCoroutine != null)
        {
            StopCoroutine(counterCoroutine);
        }
        counterCoroutine = StartCoroutine(CounterCoroutine(duration));

        IEnumerator CounterCoroutine(float duration)
        {
            isCountering        = true;
            playerInput.enabled = false;
            yield return(new WaitForSeconds(duration));

            Attack(lockedTarget, TargetDistance(lockedTarget));
            isCountering = false;
        }
    }
Example #42
0
 //bullet hits something
 void OnCollisionEnter(Collision hit)
 {
     if (networkView.isMine)
     {
         if (hit.transform.gameObject.name == "Enemy(Clone)")
         {
             EnemyScript script = hit.gameObject.GetComponent("EnemyScript") as EnemyScript;
             script.rpcGetHit(ad, sd);
         }
         if (hit.transform.gameObject.name == "EnemyTank(Clone)")
         {
             EnemyTankScript script = hit.gameObject.GetComponent("EnemyTankScript") as EnemyTankScript;
             script.rpcGetHit(ad, sd);
         }
         if (hit.transform.gameObject.name == "EnemyBomber")
         {
             EnemyBomberScript script = hit.gameObject.GetComponent("EnemyBomberScript") as EnemyBomberScript;
             script.rpcGetHit(ad, sd);
         }
         destroy();
     }
 }
    Vector2 GetPositionForAvoidance(EnemyScript ship, GameObject objectToAvoid, Vector2 targetLocation, float closestDistanceFromGroupToObject, float radiusOfFormation)
    {
        //Vector2 directionFromObjectToThis = ship.shipTransform.position - objectToAvoid.transform.position;
        float radiusOfObject = Mathf.Sqrt(Mathf.Pow(objectToAvoid.transform.localScale.x, 2) + Mathf.Pow(objectToAvoid.transform.localScale.y, 2));
        float radius         = radiusOfObject + closestDistanceFromGroupToObject + radiusOfFormation;

        Vector2[] returnee = new Vector2[2];
        returnee[0] = new Vector2(radius, 0);
        returnee[1] = new Vector2(-radius, 0);

        Vector2    dir      = (targetLocation - (Vector2)ship.shipTransform.position).normalized;
        Quaternion rotation = Quaternion.Euler(new Vector3(0, 0, (Mathf.Atan2(dir.y, dir.x) - Mathf.PI / 2) * Mathf.Rad2Deg));

        returnee[0] = (rotation * returnee[0]) + objectToAvoid.transform.position;
        returnee[1] = (rotation * returnee[1]) + objectToAvoid.transform.position;

        if (Vector2.SqrMagnitude((Vector2)ship.shipTransform.position - returnee[0]) < Vector2.SqrMagnitude((Vector2)ship.shipTransform.position - returnee[1]))
        {
            return(returnee[0]);
        }
        return(returnee[1]);
    }
Example #44
0
 void OnTriggerEnter(Collider other)
 {
     //Método que da dano no inimigo
     if (other.tag == "Enemy")
     {
         _enemyScript = other.gameObject.GetComponent <EnemyScript>();
         if (!_enemyScript.Immune)
         {
             EnemyHitDamage.Play();
             _enemyScript.hitPoints -= damage;
             if (_playerScript.transform.eulerAngles.y > 89 && _playerScript.transform.eulerAngles.y < 91)
             {
                 _enemyScript.rBody.velocity = new Vector3(12, 6, 0);
             }
             else if (_playerScript.transform.eulerAngles.y > 269 && transform.eulerAngles.y > 271)
             {
                 _enemyScript.rBody.velocity = new Vector3(-12, 6, 0);
             }
             _enemyScript.Immune = true;
         }
     }
 }
    // Basically once we figure out all of the object in the game we can see if the bullet hits one of those things, the bullet breaks
    void OnTriggerEnter2D(Collider2D collision)
    {
        // Debug.Log("Hit "+collision.tag+" for " + damage);

        if (collision.gameObject.tag == "Enemy Bullet")
        {
            // Debug.Log("Enemy Bullet");
            Destroy(gameObject);
        }
        if (collision.gameObject.tag == "HorizWall" || collision.gameObject.tag == "VerticalWall")
        {
            // Debug.Log("Wall");
            Destroy(gameObject);
        }
        if (collision.gameObject.tag == "Enemy")
        {
            // Debug.Log("Shot");
            EnemyScript enemy = collision.gameObject.GetComponent <EnemyScript>();
            enemy.DamageEnemy(damage);
            //  Debug.Log("Enemy health left: " + enemy.GetHealth());
        }
    }
Example #46
0
    /**
     * Spawn an enemy at a precise node
     */
    IEnumerator SpawnEnemy(EnemyScript enemy, Vector3Int spawnNodePos)
    {
        Vector3 spawnPos = new Vector3(spawnNodePos.x + 1, spawnNodePos.y, spawnNodePos.z + 1);     // + 1 to place the enemy at the center of a node

        //Launch spawn effect
        GameObject spawnFX = Instantiate(spawnFXObject, spawnPos, Quaternion.identity);    //Instantiate spawn effect

        spawnFX.GetComponent <ParticleSystemScript>().PlayNDestroy();

        yield return(new WaitForSeconds(0.1f));

        EnemyScript createdEnemy = Instantiate(enemy, spawnPos, Quaternion.identity, transform);  //Instantiate an enemy at spawn node, as a child of EnemyMgr

        // Add created enemy to entities list of node
        Node spawnNode = MapManager.Instance.GetNodeFromPos(spawnNodePos).GetComponent <NodeScript>().node;

        spawnNode.enemiesOnNode.Add(createdEnemy);
        spawnNode.enemyOnCenter = createdEnemy;

        // Disable enemy canvas if spawn under fog
        createdEnemy.UpdateCanvasDisplay();
    }
Example #47
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Bullet")
        {
            if (other.GetComponent <BulletScript> ().id != id)
            {
                if (other.GetComponent <BulletScript> ().team != team || team == 0)
                {
                    Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                    Destroy(gameObject);
                }
            }
        }

        EnemyScript enemy = other.GetComponent <EnemyScript> ();

        if (enemy == null)
        {
            return;
        }
        if (enemy.id == id)
        {
            return;
        }
        if (team != 0 && team == enemy.team)
        {
            return;
        }

        Instantiate(explosionPrefab, transform.position, Quaternion.identity);
        //float r = Random.Range (0f,1f);
        //float crit = (r < crit_chance) ? 1f+crit_damage : 1f;
        enemy.hp -= damage;        // * crit;
        enemy.CreateNumber(enemy.transform.position, damage.ToString(), new Color(1f, .9f, .9f), .1f, 120f, 2f);
        enemy.particleSystems[1].Play();
        enemy.audioManager.Play(0);
        enemy.StartCoroutine(enemy.FlashRoutine());
        Destroy(gameObject);
    }
Example #48
0
    void Update()
    {
        if (Input.GetButtonDown("Fire1") && Ammo.CurrentAmmo >= 1)
        {
            Shoot();
        }

        void Shoot()
        {
            RaycastHit hit;

            if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
            {
                Debug.Log(hit.transform.name);
                EnemyScript target = hit.transform.GetComponent <EnemyScript>();
                if (target != null)
                {
                    target.TakeDamage(damage);
                }
            }
        }
    }
Example #49
0
    void Update()
    {
        //Ray origin is the mouse position. Chang to reticle position when implemented.
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        //Raycast hit object
        RaycastHit hit;

        //If Raycast hits anything, draw a line of sight for debug
        if (Physics.Raycast(ray, out hit, 100)) {
            Debug.DrawLine(ray.origin, hit.point, Color.red);

            //If Mouse1 is pressed, print special attack
            if (Input.GetMouseButtonDown(0)){
                Debug.Log("Special attack fired");
                //If the raycast hits an enemy, print that it is hit
                if(hit.collider.gameObject.name == "Enemy"){
                    ES = (EnemyScript)hit.collider.gameObject.GetComponent (typeof(EnemyScript));
                    ES.TakeSA();
                    Debug.Log ("Enemy Hit");
                }
            }
        }

        //Smaller range melee attack
        if (Physics.Raycast (ray, out hit, 2)) {
            Debug.DrawLine(ray.origin, hit.point, Color.green);
            if (Input.GetMouseButtonDown(1)){
                Debug.Log("Melee Attack triggered");
                if(hit.collider.gameObject.name == "Enemy"){
                    ES = (EnemyScript)hit.collider.gameObject.GetComponent (typeof(EnemyScript));
                    ES.TakeMA();
                    Debug.Log ("Enemy Hit");
                }
            }
        }
    }
 void Awake()
 {
     _parentScript = _parent.GetComponent<EnemyScript>();
 }
 public void UnregisterEnemy(EnemyScript enemy)
 {
     mEnemies.Remove(enemy);
 }
Example #52
0
 /// <summary>
 /// Sets the Player's current enemy.
 /// </summary>
 /// <param name='enemy'>
 /// New Enemy.
 /// </param>
 public void setCurrentEnemy(EnemyScript enemy)
 {
     this.currentEnemy = enemy;
 }
 public void RegisterEnemy(EnemyScript enemy)
 {
     mEnemies.Add(enemy);
 }
Example #54
0
        public void Execute()
        {
            //If on cooldown, return
            if(Time.time < nextAttack)
                return;

            player.setRunning(false);
            player.playAnimation(animationName);

            nextAttack = Time.time + player.WeaponSpeed;
            Vector3 position = player.gameObject.transform.position;
            EnemyScript[] enemies = new EnemyScript[numPossibleTargets];
            int index = 0;
            Collider[] targets = Physics.OverlapSphere(position, radius);
            foreach(Collider t in targets){
                EnemyScript enemy = t.gameObject.GetComponent(typeof(EnemyScript)) as EnemyScript;
                if(enemy){
                    Vector3 direction = Vector3.Normalize(enemy.gameObject.transform.position - player.gameObject.transform.position);
                    float dot = Vector3.Dot(direction, player.gameObject.transform.forward);
                    if(dot > 0.707f){
                        enemies[index++] = enemy;
                        if(index > numPossibleTargets - 1) //If the maximum number of targets has been reached, stop adding new ones.
                        break;
                    }
                }
            }

            //If there are no enemies to hit, return
            if(index == 0)
                return;

            float damagePerTarget = player.WeaponDamage * 0.5f;
            foreach(EnemyScript enemy in enemies){
                if(enemy)
                    enemy.damage(damagePerTarget);
            }

            player.lastCombatTime = Time.time;
        }
Example #55
0
 /// <summary>
 /// Performs a simple auto-attack on the specified player. The calling procedure is responsible
 /// to ensure that the auto-attack is only called when off cooldown.
 /// </summary>
 /// <returns>
 /// The new cooldown of the auto-attack.
 /// </returns>
 /// <param name='enemy'>
 /// The enemy to attack.
 /// </param>
 public float autoAttack(EnemyScript enemy)
 {
     a.Stop();
         setRunning(false);
         a.Play("Attack" + (((int)(Random.value * 3)) + 1));
         enemy.damage(WeaponDamage);
         ValorDebuff debuff = new ValorDebuff(valorDebuffTexture);
         enemy.applyDebuff(debuff, true);
         lastCombatTime = Time.time;
         stunTime = Time.time + 1f; //Delay after attack
         return Time.time + WeaponSpeed;
 }
    public void PerformHeal()
    {
        if (startOfHeal == true) {
            healTimer = 60;
            startOfHeal = false;
        }
        if (state == "Healing" && healTimer > 0)
        {
            gameObject.renderer.material.color = Color.green;
            healTimer--;
        }
        else
        {
            Debug.Log (this.name+" successfully healed.");
            successfullyAttacked = true;
            if(uiScript.enemy.Count > 0)
            {
                float healRoll = uiScript.GetStatsScript().HealRoll(gameObject.name);
                if (healTarget != null)
                {
                    if (!healTarget.gameObject.activeSelf || healTarget.health <= 0)
                        healTarget = this;
                }
                else
                    healTarget = this;

                healTarget.ReceiveHeal(healRoll);
                attackTimer = attackDelay;
                startOfHeal = true;
                state = "Standby";
                uiScript.WakeUp ();
            }
            else if(uiScript.deadEnemies.Count > 0){
                uiScript.deadEnemies.Clear ();
                SelectAttackTarget();
                InitiateAttackSequence();
                state = "Attacking";
                MoveToAttack();
            }

        }
    }
 public void selectEnemyTarget()
 {
     //This is for enemy selection
     if (Input.GetButtonDown ("Click") && state == "AttackTargetSelect")
     {
         GameObject clickedGameObject = GetMouseoverGameObject ();
         if (clickedGameObject != null)
         {
             if (clickedGameObject.tag == "Enemy")
             {
                 if (clickedGameObject.GetComponent<EnemyScript>().GetState() != "Dead")
                 {
                     enemyTarget = clickedGameObject.GetComponent<EnemyScript>();
                     Debug.Log ("Selected "+enemyTarget.name+" as attack target.");
                     currentHero.SetTarget(enemyTarget);
                     EnqueuePlayer(currentHero.gameObject);
                     selectCircle.Refresh ();
                 }
             }
             else if (clickedGameObject.tag == "Player")
             {
                 selectCircle.Refresh ();
                 SetCircleToPlayer();
                 currentHero = clickedGameObject.GetComponent<PlayerScript>();
                 Debug.Log ("Selected "+currentHero.name+" to attack.");
                 DisplayMainBattleMenu();
             }
         }
     }
     else if (Input.GetButtonDown ("Click") && state == "HealTargetSelect")
     {
         GameObject clickedGameObject = GetMouseoverGameObject ();
         if (clickedGameObject != null)
         {
             if (clickedGameObject.tag == "Enemy")
             {
                 if (clickedGameObject.GetComponent<EnemyScript>().GetState() != "Dead")
                 {
                     enemyTarget = clickedGameObject.GetComponent<EnemyScript>();
                     Debug.Log ("Selected "+enemyTarget.name+" as heal target.");
                     currentHero.SetTarget(enemyTarget);
                     EnqueuePlayer(currentHero.gameObject);
                     selectCircle.Refresh ();
                 }
             }
             else if (clickedGameObject.tag == "Player")
             {
                 if (clickedGameObject.GetComponent<PlayerScript>().GetState() != "Dead")
                 {
                     PlayerScript pTarget = clickedGameObject.GetComponent<PlayerScript>();
                     Debug.Log ("Selected "+pTarget.name+" as heal target.");
                     currentHero.SetTarget(pTarget);
                     EnqueuePlayer(currentHero.gameObject);
                     selectCircle.Refresh ();
                 }
             }
         }
     }
 }
    public void RemoveMe(EnemyScript deadEnemy)
    {
        enemy.Remove (deadEnemy);

        if (attackUnderway)
            attackUnderway = false;

        if (attackOrder.Contains (deadEnemy.gameObject))
        {
            Queue<GameObject> temp = new Queue<GameObject>();
            for (int i = 0; i < attackOrder.Count; i++)
            {
                GameObject tempObject  = attackOrder.Dequeue ();
                if (tempObject != deadEnemy)
                    temp.Enqueue (tempObject);
            }
            attackOrder = temp;
        }
    }
Example #59
0
 // Use this for initialization
 void Start()
 {
     // Get access to the enemy script
     EnemyInfo = GetComponent<EnemyScript>();
 }
 public void PerformTurn()
 {
     if (state == "Attacking")
     {
         if (successfullyAttacked)
         {
             MoveBackToStartPosition ();
         }
         else
         {
             MoveToAttack ();
         }
     }
     if (state == "Healing") {
         if(!successfullyAttacked){
             healTarget = aiScript.SelectHealTarget ();
             PerformHeal();
         }
     }
 }