예제 #1
0
    //apply damage and effects to all enemies in This zone
    void Blast()
    {
        dial = GameObject.Find("Dial").GetComponent <Dial>();
        List <Enemy> enemyList = Dial.GetAllEnemiesInZone(zoneID);

        for (int i = 0; i < enemyList.Count; i++)
        {
            if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
            {
                float ehp = enemyList[i].GetHP();
                if (ehp < damage * vampDrain)
                {
                    dial.ChangeHealth(ehp);
                }
                else
                {
                    dial.ChangeHealth(damage * vampDrain);
                }
            }
            enemyList[i].TakeDamage(damage);
            if (parentShield != null && enemyList[i] != null)
            {
                enemyList[i].ShieldInflictedStatus(parentShield);
            }
        }
    }
예제 #2
0
    void BeginMerge()
    {
        //get everything in the lane
        List <Enemy> zoneGuys = Dial.GetAllEnemiesInZone(SpawnIndexToZoneID(mergeIdx));

        if (zoneGuys.Count < 2)
        {
            //abort merge and move on
            Debug.Log("not enough enemies, merge aborted");
            PickTargetZone();
            hitYet       = false;
            currentState = state.DECIDING;
            return;
        }
        //create facsimilies
        facsimiles.Clear();
        Vector2 centerTotals = new Vector2(0f, 0f);
        float   progTotals   = 0f;

        foreach (Enemy e in zoneGuys)
        {
            GameObject facs = GameObject.Instantiate(e.gameObject);
            GameObject.Destroy(facs.GetComponent <Enemy>());
            facs.tag = "Untagged";
            MegaboidFacsimile mf = facs.AddComponent <MegaboidFacsimile>() as MegaboidFacsimile;
            facs.transform.SetParent(Dial.spawnLayer, false);
            facsimiles.Add(facs);
            //get their centers
            centerTotals += e.gameObject.GetComponent <RectTransform>().anchoredPosition;
            progTotals   += e.GetProgress();
        }
        center     = new Vector2(centerTotals.x / zoneGuys.Count, centerTotals.y / zoneGuys.Count);
        progcenter = progTotals / zoneGuys.Count;
        foreach (GameObject mfg in facsimiles)
        {
            mfg.GetComponent <MegaboidFacsimile>().InitializeMovement(center, mergeTimer);
        }

        //old guys: kill 'em all
        foreach (Enemy e in zoneGuys)
        {
            Dial.CallEnemyAddBonus(e);
        }
        foreach (Enemy e in zoneGuys)
        {
            Destroy(e.gameObject);
        }

        currentState = state.MERGING;
        mergeTimer.Restart();
    }
예제 #3
0
    public override void Update()
    {
        if (!moving)
        {
            base.Update();
            return;
        }
        base.Update();

        if (!sittingThere && progress > 0.5f)
        {
            sittingThere           = true;
            steering.allowedToMove = false;
        }

        if (blowingUp)
        {
            if (blastTimer.TimeElapsedSecs() >= blastDuration)
            {
                blowingUp = false;
                //hurt dial
                GameEvent boom = new GameEvent("dial_damaged");
                boom.addArgument(this.gameObject);
                boom.addArgument(blastDamage);
                EventManager.Instance().RaiseEvent(boom);
                //hurt boss if applicable
                GameObject bossObj = GameObject.FindWithTag("Boss");
                if (bossObj != null)
                {
                    Boss b = bossObj.GetComponent <Boss>();
                    b.TakeDamage(blastDamage);
                }
                //hurt enemies
                List <Enemy> casualties = Dial.GetAllEnemiesInZone(GetCurrentTrackID());
                foreach (Enemy e in casualties)
                {
                    if (e != this)
                    {
                        e.TakeDamage(blastDamage);
                    }
                }
                base.Die();
            }
        }
    }
예제 #4
0
    public void PrepTargets()
    {
        targets = Dial.GetAllEnemiesInZone(SpawnIndexToZoneID(thingIdx));
        if (mode == 0)
        {
            List <System.Object> fragList = new List <System.Object>();
            Dictionary <string, System.Object> fragDict = new Dictionary <string, System.Object>();
            fragDict.Add("fragAngle", 0.0);
            fragDict.Add("fragArc", 360.0);
            fragList.Add(fragDict);

            foreach (Enemy e in targets)
            {
                e.Freeze();
                if (e.GetShield() == null)
                {
                    e.GiveShield(10f, 2f, 0.04f, fragList);
                    //e.GetShield().GrowShields();
                }
                else
                {
                    e.GetShield().IncreaseAllShieldHP(10f);
                }
            }
        }
        else if (mode == 1)
        {
            for (int i = 0; i < targets.Count; i++)             //remove unshielded enemies from targets
            {
                if (targets[i].GetShield() == null)
                {
                    targets.RemoveAt(i);
                    i--;
                }
            }
            particleTimer = new Timer();
            foreach (Enemy e in targets)
            {
                e.GetShield().bulked = true;
                e.Freeze();
            }
        }
    }
예제 #5
0
    public override void Update()
    {
        Debug.Log("hit yet: " + hitYet + ", mode: " + mode + ", state: " + currentState);
        base.Update();
        moving = !GamePause.paused;
        if (!moving)
        {
            return;
        }

        //handle movement and merging
        if (currentState == state.DECIDING)
        {
            goingRight   = !ShouldWeGoLeft(mergepoints[mergeIdx]);           //pick a direction to move in
            currentState = state.MOVING;
        }
        else if (currentState == state.MOVING)
        {
            Arrive();
        }
        else if (currentState == state.BOUNCING)
        {
            if (bounceLeft)
            {
                if (thetas.y < 0)
                {
                    thetas.y     = 0;
                    currentState = state.DECIDING;
                }
            }
            else
            {
                //Debug.Log("thetas: " + thetas.x + "," + thetas.y + "," + thetas.z);
                if (thetas.y > 0)
                {
                    thetas.y     = 0;
                    currentState = state.DECIDING;
                }
            }
        }
        else if (currentState == state.SPAWNING)
        {
            System.Random rand    = new System.Random();
            List <Enemy>  enemies = Dial.GetAllEnemiesInZone(SpawnIndexToZoneID(mergeIdx));
            bool          hasBlob = false;
            bool          hasMega = false;
            foreach (Enemy e in enemies)
            {
                if (e.GetSrcFileName().Equals("blob"))
                {
                    hasBlob = true;
                }
                if (e.GetSrcFileName().Equals("megasplit") || e.GetSrcFileName().Equals("minisplit"))
                {
                    hasMega = true;
                }
            }
            //decide whether to drop an enemy, and which one
            if (hasBlob)
            {
                if (hasMega)
                {
                    BeginMerge();
                    return;                     //short circuit this update so the next frame is in the MERGING state
                }
                else
                {
                    DropMegasplit();
                }
            }
            else
            {
                if (hasMega)
                {
                    DropBlob();
                }
                else
                {
                    if (rand.NextDouble() < 0.5)
                    {
                        DropMegasplit();
                    }
                    else
                    {
                        DropBlob();
                    }
                }
            }
            //end spawn state
            PickTargetZone();
            hitYet       = false;
            currentState = state.DECIDING;
        }
        else if (currentState == state.MERGING)
        {
            //update enemy facsimiles if necessary

            //check if it's time to move on, then move on
            if (mergeTimer.TimeElapsedSecs() >= mergeDelay || mode == 0)
            {
                FinishMerge();
                PickTargetZone();
                hitYet       = false;
                currentState = state.DECIDING;
            }
        }
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        age += Time.deltaTime;         //update the age

        if (armTime <= 0.0f && !isActive)
        {
            Debug.Log("armTime is 0 or less!");
            isActive = true;
            Debug.Log("trap armed!");
        }
        //traps don't move so no changes in its position after placement
        //they need to count down to become active
        if (armTime > 0.0f)            //if it's still counting down
        {
            armTime -= Time.deltaTime; //update arming countdown time
            Debug.Log("armTime = " + armTime);
            if (armTime <= 0.0f)       //if it's done counting down, activate the trap
            {
                isActive = true;
                Debug.Log("trap armed!");
            }
        }
        if (firingDupes)
        {
            if (duplicateTimer.TimeElapsedSecs() > duplicateDelay)
            {
                if (duplicatedTimes < duplicate)
                {
                    FireEffect();
                    duplicateTimer.Restart();
                    duplicatedTimes++;
                    if (duplicatedTimes >= duplicate)
                    {
                        usesLeft--;
                        if (usesLeft <= 0)
                        {
                            Debug.Log("dupe trap expended");
                            Destroy(this.gameObject);
                        }
                        firingDupes     = false;
                        duplicatedTimes = 0;
                    }
                }
                else
                {
                    Debug.Log("trap duplicate power shouldn't reach here");
                }
            }
        }
        if (attraction != 0.0f)
        {
            List <Enemy> inRange = Dial.GetAllEnemiesInZone(zone);
            foreach (Enemy e in inRange)
            {
                Vector2  attractionVector = rt.anchoredPosition - e.GetComponent <RectTransform>().anchoredPosition;
                Vector2  direction        = attractionVector.normalized;
                float    distFromTrap     = attractionVector.magnitude;
                Steering s            = e.GetComponent <Steering>();
                float    strength     = s.maxAccel * 0.99f;               //baseline maximum
                float    percentOfMax = attraction / TEMP_MAX_ATTRACTION; //use attraction number to get how close to the max attraction you're at
                strength *= percentOfMax;                                 //multiply to get acceleration
                Vector2 adjusted = direction * strength;                  //then apply that to the direction vector
                s.ExternalForceUpdate(this, adjusted);                    //and tell the AI to be pulled that way
            }
        }
    }