void OnDestroy()
    {
        //Do a check for GOT incase its not there.
        if (!GameObjectTracker.GetGOT())
        {
            return;
        }

        if (currentWave)
        {
            //If we are destroyed at a boss level that means we have updated to a new phase while boss still exists
            //or updated via boss battle itself.

            if (Boss)
            {
                //Send the message for boss being completed
                GameObjectTracker.GetGOT().BossWaveCompleted();

                //Pop the music.
                AudioPlayer.GetPlayer().PopTrack();
            }


            //Clean up our waves upon our destruction
            Destroy(currentWave.gameObject);
        }
    }
Пример #2
0
    public void PopulateCannonsList()
    {
        // We have the activity.  Populate the grid with Cannons!!
        EntityFactory ef = EntityFactory.GetEF();

        if (ef == null)
        {
            return;
        }

        // Getting ItemCards from Playerdata to populate list based on item cards not the entity factory calalog
        GameObjectTracker go = GameObjectTracker.GetGOT();

        if (go == null)
        {
            return;
        }

        if (_CardSelectors == null)
        {
            return;
        }

        // keeping track of the list of cannon selection objects locally

        // the next object to temp strore data for the list
        CannonSelectionObject newCannon = null;


        // Grab the deck of cards from the player data
        allItemCards = go._PlayerData.CardDeck;

        int cannonItemCardIndex = 0;

        foreach (CannonItemCard canItem in allItemCards)
        {
            //Create cannon and assign the reference.
            newCannon = NGUITools.AddChild(_gridOfCannons.gameObject, _refPrefab.gameObject).GetComponent <CannonSelectionObject>();
            newCannon.MyCannonCard = canItem;

            //Set the checkbox root.
            UICheckbox cbox = newCannon.GetComponent <UICheckbox>();
            if (cbox)
            {
                cbox.radioButtonRoot = this.transform;
            }

            _gridOfCannons.Reposition();

            _CardSelectors.Add(newCannon);

            cannonItemCardIndex++;
        }

        //Is populated is true,
        isPopulated = true;

        //And list give the list to the activity manager so they can grab it.
        ActivityManager.Instance.CardSelectors = _CardSelectors;
    }
    void Init()
    {
        if (GameObjectTracker.GetGOT())
        {
            //Set default data.
            if (pdata == null)
            {
                pdata = GameObjectTracker.GetGOT().FullStatistics;
            }


            int index = 0;
            foreach (Statistics.DataEntry data in pdata.AllDataEntries)
            {
                FUIStatObject newStat = null;

                // add the new stat as a child to the table
                newStat = NGUITools.AddChild(myTable.gameObject, refStatObject.gameObject).GetComponent <FUIStatObject>();

                //Set the data first so we can assign the value upon assigning the statistic reference.
                newStat.StatType = data.EntryType;
                newStat.myStat   = pdata;

                statObjects.Add(newStat);

                myTable.Reposition();
                index++;
            }

            isFullyInit = true;
        }
    }
    // Update is called once per frame
    void Update()
    {
        gems = GameObjectTracker.GetGOT().GetGemsCollected();

        myLabelText  = "" + gems + "";
        myLabel.text = myLabelText;
    }
Пример #5
0
    public void Damage(float deg)
    {
        if (DefenseUnitSlot == null)
        {
            Debug.LogWarning("No DefensiveSlot in BOT Damage");
            return;
        }
        if (!DefenseUnitSlot.IsActivated())
        {
            AddHeat(deg);

            if (HurtSound)
            {
                AudioPlayer.GetPlayer().PlaySound(HurtSound);
            }

            if (DamageEffect)
            {
                DamageEffect.Play();
            }
        }

        //Register with GOT.
        GameObjectTracker.GetGOT().PlayerHit(deg);
    }
Пример #6
0
    public void AssignSlot(EntityFactory.CannonTypes type, int index)
    {
        //Assign the player data type.
        GameObjectTracker.GetGOT()._PlayerData.AssignSlot(type, index);

        //Set the command center.
        //CommandCenter_01.SetCannonSlot(GameObjectTracker.GetGOT()._PlayerData.CannonSlots[index],index);

        //New code for slots.
        //CommandCenter_01.SetItemSlot(GameObjectTracker.GetGOT()._PlayerData.ItemSlots[index],index);

//		//Write to the player data.
//		if(index == 0)
//		{
//			//Temp
//			GameObjectTracker.GetGOT()._PlayerData.CannonSlotA = type;
//			GameObjectTracker.GetGOT()._PlayerData.CannonSlots[index] = type;
//
//			//Set the command center.
//			CommandCenter_01.SetCannonSlot(GameObjectTracker.GetGOT()._PlayerData.CannonSlotA,index);
//
//		}
//
//		//Write to the player data.
//		if(index == 1)
//		{
//			GameObjectTracker.GetGOT()._PlayerData.CannonSlotB = type;
//
//			//Set the command center.
//			CommandCenter_01.SetCannonSlot(GameObjectTracker.GetGOT()._PlayerData.CannonSlotB,index);
//
//		}
    }
    // Use this for initialization
    protected virtual void Start()
    {
        //Add a phase to the statistics every time we create a new phase.
        GameObjectTracker.GetGOT()._PlayerData.AddPhase(CopyPhaseData());

        //Play the audio track.
        AudioPlayer.GetPlayer().PlayAudioClip(PhaseSoundtrack);
    }
    // Update is called once per frame
    void Update()
    {
        float localTimer = GameObjectTracker.GetGOT().localTargetTimer;
        int   points     = GameObjectTracker.GetGOT().GetCurrentPoints();
        float pps        = points / localTimer;

        myLabel.text = "" + pps;
    }
    protected void HandleWaveCreation()
    {
        if (!currentWave)
        {
            //If boss flag is true spawn a boss wave!
            if (Boss)
            {
                //Create a boss wave.
                currentWave = CreateBossWave();

                //Send the message for boss started
                GameObjectTracker.GetGOT().BossWaveStart();

                //Store the time off the current music so we can resume.
                //currentaudiotime = AudioPlayer.GetPlayer().audio.time;

                //Set and play the boss music.
                //AudioPlayer.GetPlayer().PlayAudioClip(BossSoundtrack);

                //Push the boss sound track.
                AudioPlayer.GetPlayer().PushTrack(BossSoundtrack);

                return;
            }

            currentWave = CreateWave();
        }

        if (currentWave.IsCompleted())
        {
            //If it was a boss wave do boss clean up stuff here.
            if (Boss)
            {
                //turn boss off.
                Boss = false;

                //Incriment the count of bosses destroyed.
                bossWaveCount++;

                //Send the message for boss being completed
                GameObjectTracker.GetGOT().BossWaveCompleted();

                //Return to our regular music programming.
                //AudioPlayer.GetPlayer().PlayAudioClip(PhaseSoundtrack,currentaudiotime);

                //Pop from the boss track.
                AudioPlayer.GetPlayer().PopTrack();
            }

            //print("Wave Completed!");
            Destroy(currentWave.gameObject);
            wavesDestroyedCount++;
            totalWavesDestroyed++;

            //Send the message for wave being completed
            GameObjectTracker.GetGOT().WaveCompleted();
        }
    }
 //Checks the combo required to mark the phase as complete.
 protected void CheckComboCompletion()
 {
     //Get the GOT's multiplier count and check if we reached the combo required.
     if (GameObjectTracker.GetGOT().GetMultiplier() >= ComboCompletionRequirement ||
         bossWaveCount >= BossCompletionRequirement)
     {
         Completed = true;
     }
 }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        phaseDataList = GameObjectTracker.GetGOT()._PlayerData.Breathless.PhaseList;


        if (phaseDataList != null && phaseCount < phaseDataList.Count)
        {
            // if we have a data list, and the data list is greater than the number
            // of phases we have created, the last phasecount "Should" be the last
            // punched phase, grab that and create the result object and add it to the grid.

            BasePhase.PhaseData lastPhaseData = phaseDataList[phaseCount];

            // after all is done, increment our phase count
            phaseCount++;

            FUIPhaseResultObject newPhaseResult = null;
            newPhaseResult = NGUITools.AddChild(myGrid.gameObject, refPhaseResultObject.gameObject).GetComponent <FUIPhaseResultObject>();
            if (lastPhaseData.PhaseCompletionPunch < 0)
            {
                newPhaseResult.phaseSprite.spriteName = "phaseunknown";
                newPhaseResult.phaseLabel.text        = "Failed";
            }
            else
            {
                newPhaseResult.phaseSprite.spriteName = lastPhaseData.IconTextureName;
                newPhaseResult.phaseLabel.text        = FormatSeconds(lastPhaseData.PhaseCompletionPunch);
                //newPhaseResult.PhaseData = lastPhaseData;
            }
            // regardless if the phases is punched or not, store the given phase name
            // this way when it gets punched, we can update the data
            newPhaseResult.givenSpriteName = lastPhaseData.IconTextureName;

            phaseResults.Add(newPhaseResult);

            // now we've added any new phases that we need.
            // real quick iterate through the lists, and update any new phases that
            // have now been punched
            for (int i = 0; i < phaseCount; i++)
            {
                if (phaseDataList[i].PhaseCompletionPunch > 0)
                {
                    phaseResults[i].phaseSprite.spriteName = phaseResults[i].givenSpriteName;
                    phaseResults[i].phaseLabel.text        = FormatSeconds(phaseDataList[i].PhaseCompletionPunch);
                    phaseResults[i].PhaseData = phaseDataList[i];
                }
            }

            myGrid.Reposition();

            // update the phase title
            if (labelPhaseResultsTitle)
            {
                labelPhaseResultsTitle.text = phaseResultsTitles[phaseCount];
            }
        }
    }
    }    //All Collisions ON Stay Check

    protected void ProcessBotandCCTouchDamage(Collision col)
    {
        //We must make sure we have a self... if not.. well... return!
        if (self == null)
        {
            return;
        }

        // when was the last time we did damage?  able to do damage every two seconds

        if (!canTouchDamage)
        {
            return;
        }

        //Check if we collide with a CommandCenter.
        if (col.gameObject.CompareTag("CommandCenter") && (!self.IsDestroyed()))         //&& selfAsEnemy.AttackCommandCenters))
        {
            CommandCenter c = col.gameObject.GetComponent <CommandCenter>();

            c.Damage(TouchDamageToCC);
            self.Damage(touchDamageToSelf);                      // this may not kill me
            // we do our damage, set can do damage off and hit the clock
            canTouchDamage   = false;
            touchDamageClock = Time.time;

            //Send the detonation message to the GOT
            GameObjectTracker.GetGOT().TargetDetonated();
        }
        //Check if we collide with a Player Bot
        //TODO:CRashing here.
        if (col.gameObject.CompareTag("Bot") && (!self.IsDestroyed()))         //&& selfAsEnemy.AttackBots))
        {
            Bot b = col.gameObject.GetComponent <Bot>();

            //Dont blow up if shield is active.
            if (b.IsShieldActive())
            {
                return;
            }

            b.Damage(TouchDamageToBot);
            self.Damage(touchDamageToSelf);              // this may not kill me

            //Send the detonation message to the GOT
            GameObjectTracker.GetGOT().TargetDetonated();
            // we do our damage, set can do damage off and hit the clock
            canTouchDamage   = false;
            touchDamageClock = Time.time;
        }



        // end processing bot and cc
    }
Пример #13
0
    public override void BossCompleted()
    {
        //If we complete a boss on game over we stick to the boss level.
        if (gameover)
        {
            return;
        }

        //Just play the animation for now.
        GameObjectTracker.GetGOT().vWorld.ActivateBossRoom(false);
    }
Пример #14
0
    public void SetDataEntry(Statistics stats)
    {
        GameStatistics = stats;

        //Calculate pps.
//		int score =  GameStatistics.Score;
//		float pps = (float)score/GameStatistics.TimeAmount;


        //Set the score text to PPS.
        //ScoreText.text = GameObjectTracker.GetGOT().GamePPS.ToString();
        ScoreText.text = GameObjectTracker.GetGOT().RunStatistics.PPS.ToString();
    }
        //Returns true if successful and there has been stats assigned to the mission.
        public bool SetObjectiveNameObject(string missionName, int index = 0)
        {
            string objstatname = missionName + "_ObjStats" + index + "_" + ObjectiveLabel;

            //Check if there are no stats yet assigned to the objective then we return
            if (_objectiveStats == null)
            {
                //Here is where we can check for the already existing objective stat.
                //Lets look for the objects already in the scene to assign upon reload.
                foreach (Object o in FindSceneObjectsOfType(typeof(Statistics)))
                {
                    if (o.name == objstatname)
                    {
                        _objectiveStats = (Statistics)o;

                        //remake parent.

                        DontDestroyOnLoad(_objectiveStats.gameObject);

                        //Return false that object did not exist.
                        return(false);
                    }
                }

                //This is where the creation takes place
                _objectiveStats = Instantiate(GameObjectTracker.GetGOT()._PlayerData.BlankStatistics) as Statistics;

                //Apply the mission name to the objective label
                _objectiveStats.name = objstatname;


                //Lets load since we are created.
                _objectiveStats.LoadFromPlayerPrefs();

                //Keep this lil guy around.
                DontDestroyOnLoad(_objectiveStats.gameObject);

                //Return false that object did not exist.
                return(false);
                //print("Stat Created!!!!!!!!!!!!!!!!!!:" + objstatname);
            }

            //Apply the mission name to the objective label
            _objectiveStats.name = objstatname;


            //Print the name
//			print("ObjStats Name Set: " + _objectiveStats.name);
            return(true);
        }
Пример #16
0
    public override void CannonPickedUp()
    {
//		//If we are at the intro stage, move on to the start of the game upon picking up the cannon.
        if (currentState == LevelStates.Introduction)
        {
            //Begin the phasing level.
            currentState = LevelStates.Phasing;

            //Stop our audio.
            //audio.Stop();

            //Start teh game statistics counter.
            GameObjectTracker.GetGOT().StartGame();
        }
    }
Пример #17
0
    public void AssignCannonSlotTypes()
    {
        PlayerData _pd = GameObjectTracker.GetGOT()._PlayerData;

        //Set the cannon types.
        for (int i = 0; i < _pd.ItemSlots.Length; i++)
        {
            CommandCenter_01.SetItemSlot(_pd.ItemSlots[i], i);
        }

        CommandCenter_01.TriggerSlotSpawns();

        //Copy slots to active slot array
        _pd.ClearGameSlots();

        //Clear the slots after assigning
    }
Пример #18
0
    //Information linking the actual item.
    protected virtual void Start()
    {
        if (_itemStatistics == null)
        {
            //Create the stat object if there is none. and set its name and parent.
            _itemStatistics                  = Instantiate(GameObjectTracker.GetGOT()._PlayerData.BlankStatistics) as Statistics;
            _itemStatistics.name             = "IC_" + this.Label + "_ItemStats";
            _itemStatistics.transform.parent = this.transform;

            //And load if we are awake and there is no item.
            _itemStatistics.LoadFromPlayerPrefs();
        }


        Init();

        //	print("Base Item Card Start : End");
    }
Пример #19
0
    /// <summary>
    /// Over heat function that is called when the current temperature exceeeds the maximum temperature capability.
    /// This function will handle all the code for when a bot over heats.
    /// </summary>
    void OverHeat()
    {
        //Set the timestamp for overheating
//		pickuptimestamp = Time.time;
//
//		//Play the over heated effect.
//		if(OverheatEffect)
//		{
//			OverheatEffect.Play();
//		}
//
//
//		//First things first is we detach teh cannon now dont we?
//		connectorcontroller.DetachCannon();

        //Send the message
        GameObjectTracker.GetGOT().PlayerOverHeated();

        //Hide the temp guage.
        isTempVisible = false;
    }
Пример #20
0
    public override void ReceiveCollisionInfo(Collision col)
    {
        //Check if we collide with a CommandCenter.
        if (col.gameObject.CompareTag("Target"))
        {
            Target t = col.gameObject.GetComponent <Target>();
            // if we touch the command Center add health,
            // but only certain amount per second
            if (isAffective && !t.IsDestroyed() && (Time.time - timeStartedDoingDamage) > damageDoingFreq)
            {
                // TODO: for now, we are going to add negative damage, should work
                t.Damage(damageToDeal);
                // print("Doing +" + damageToDeal + " Damage to Target!");

                //Call the message
                GameObjectTracker.GetGOT().DeathBeamAttack();

                timeStartedDoingDamage = Time.time;
            }
        }
    }
    PhaseData CopyPhaseData()
    {
        //Copy over the phase data to the struct for player data.
        data = new PhaseData();

        data.ComboToComplete  = ComboCompletionRequirement;
        data.BossesToComplete = BossCompletionRequirement;
        data.WavesToBoss      = WaveCountForBoss;
        data.ScoreMultiplier  = ScoreMultiplier;
        data.Description      = Description;
        data.IconTextureName  = IconTextureName;

        data.Label = "Phase Name: " + this.name;

        data.PhaseStatistics = GameObjectTracker.GetGOT().PushStatistics("PhaseStat_" + this.name, ScoreMultiplier);

        //Set the name of the phase so we can find in the scene view easily.
        name = "GamePhase_" + name;

        return(data);
    }
Пример #22
0
    public void Shoot()
    {
        //Have to make sure we have a cannon
        if (!connectorcontroller.GetCannon())
        {
            return;
        }

        if (IsShieldActive())
        {
            return;
        }

        //Add a pushback force.
        float f = connectorcontroller.GetCannon().GetPushBackFactor() * PushBackForceFactor;

        Rdbdy.AddForce(myTransform.forward * -f);

        //And we call the cannon's shoot inside the add heat function.
        AddHeat(connectorcontroller.GetCannon().Shoot());

        //Send the message
        GameObjectTracker.GetGOT().PlayerShoot();
    }
Пример #23
0
    public void OnBlockBall(Ball b)
    {
        if (DefenseUnitSlot.CanDeflect)
        {
            //Change the properties of the ball.
            //b.SetBallSourceID(Ball.BallSourceID.Deflect);


            //b.SetDamageAmount(DefenseUnitSlot.ReflectDamage);
            b.SetMaterial(DefenseUnitSlot.GetReflectMaterial());
            b.EnableTrail();

            //Cap the damage amount
            if (b.DamageAmount < DefenseUnitSlot.ReflectDamage)
            {
                b.SetDamageAmount(DefenseUnitSlot.ReflectDamage);
            }

            //Force setting part.

            //We get the forward vector of the self.
            Vector3 baseDirection = reflectForce;
            baseDirection += myTransform.forward;
            baseDirection += myTransform.forward;

            Vector3 bposition = b.transform.position;

            //Scale the force by the mass and a set amount for now.
            baseDirection *= (b.GetComponent <Rigidbody>().mass *DeflectForceFactor);

            //Zero out the ball velocity.
            b.GetComponent <Rigidbody>().velocity = Vector3.zero;

            //Almost last but not least we call dont tax so you dont get the activation fee when you deflect a ball
            DefenseUnitSlot.DontTax();

            //Grab the x magnitude and test
            float xdir = Mathf.Abs(reflectForce.x);


            //If we have any direction but holdingback we add force to the ball and play sound.
            if (reflectForce.z >= InputBackBuffer)
            {
                //Ensure drag is set back to original.
                b.ResetDrag();

                //Add the throwing force.
                b.GetComponent <Rigidbody>().AddForce(baseDirection, ForceMode.Force);

                //Set the reset timer to die shortly after.
                b.HotLifeTime = 2.0f;
                b.ResetTimer(0.5f);

                if (DeflectEffect)
                {
                    //Apply the effect on the target.
                    Quaternion r = Quaternion.LookRotation(baseDirection);
                    DeflectEffect.transform.rotation = r;

                    DeflectEffect.Play();
                }


                if (b.GetBallSourceID() != Ball.BallSourceID.Capture)
                {
                    //Set the source ID.
                    b.SetBallSourceID(Ball.BallSourceID.Deflect);
                }

                //Send the message.
                GameObjectTracker.GetGOT().DeflectedBall();

                //Play the sound file.
                if (ReflectSound)
                {
                    AudioPlayer.GetPlayer().PlaySound(ReflectSound);
                }

                //Cool when we deflect.
                Cool(BlockingCoolDownFactor);
            }
            else
            {
                if (IsCannonAttached())
                {
                    //Zero out the velocity here.
                    //b.rigidbody.velocity = Vector3.zero;

                    b.ResetTimer(DeflectHoldingTime);
                    b.SetDrag(10.0f);

                    //Send the message.
                    GameObjectTracker.GetGOT().CaptureBall();

                    //Set the source ID.
                    b.SetBallSourceID(Ball.BallSourceID.Capture);


                    //Play the sound file.
                    if (CaptureSound)
                    {
                        AudioPlayer.GetPlayer().PlaySound(CaptureSound);
                    }

                    //Play particle effect
                    if (CaptureBallEffect)
                    {
                        CaptureBallEffect.transform.localPosition = bposition;
                        CaptureBallEffect.Play();
                    }

                    //Cool down the bot when we block.
                    Cool(BlockingCoolDownFactor);
                    //AddHeat(b.DamageAmount * 0.5f);
                }
            }
        }
        else
        {
            b.Pop();

            //Play the sound file.
            if (BlockSound)
            {
                AudioPlayer.GetPlayer().PlaySound(BlockSound);
            }


            //play the blocking effect here.
            if (BlockEffect)
            {
                BlockEffect.Play();
            }

            //Cool down the bot when we block.
            //Cool(BlockingCoolDownFactor * 0.32f);
            AddHeat(b.DamageAmount * 0.5f);

            GameObjectTracker.GetGOT().BlockedBall();
        }


        //If we are performing a move, set can deflect to false to only do the move once per animation.
        //DefenseUnitSlot.CanDeflect = false;
    }
Пример #24
0
    public void OnMelee(Target t, float speed, bool canShatter)
    {
        //We must be in deflect timing!
        if (!DefenseUnitSlot.CanDeflect)
        {
            //Whatever we want to register when the shield touches a target outside of the deflect window.

            //And return.
            return;
        }
        ;



        //Lets store the position here in case we need it. quick access
        Vector3   Tposition = t.transform.position;
        Vector3   forward   = transform.forward;
        Rigidbody trigid    = t.GetComponent <Rigidbody>();

        //Force setting part.

        //We get the forward vector of the self.
        Vector3 baseDirection = reflectForce;

        baseDirection += forward;
        baseDirection += forward;


        //Scale the force by the mass and a set amount for now.
        float pf = DefenseUnitSlot.VelocityReflectFactor;

        //If our mass is below the push force, then push at the masses base.
        if (t.GetComponent <Rigidbody>().mass < pf)
        {
            pf = t.GetComponent <Rigidbody>().mass;
        }


        baseDirection *= (pf * DeflectForceFactor);

        //If we are pushing things we cant shatter then we wont push them nearly as much.
//		if(!canShatter)
//		baseDirection *= DeflectCCScale;

        //Zero out the ball velocity.
        trigid.velocity = Vector3.zero;



        //Almost last but not least we call dont tax so you dont get the activation fee when you deflect a ball
        DefenseUnitSlot.DontTax();

        //Grab the x magnitude and test
        float xdir = Mathf.Abs(reflectForce.z);

        //If we have any direction but holdingback we add force to the ball and play sound.
        //if(reflectForce.z >= 0.0f)
        if (reflectForce.z >= InputBackBuffer)
        {
            //Play the sound file.
            if (MeleeSound)
            {
                AudioPlayer.GetPlayer().PlaySound(BlockSound);
                AudioPlayer.GetPlayer().PlaySound(MeleeSound);
            }


            //Add the throwing force.
            trigid.AddForce(baseDirection, ForceMode.Force);

            //Take away the constraints.
//			if(!canShatter)
//			trigid.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
//
            if (ShieldPushEffect)
            {
                //Apply the effect on the target.
                Quaternion r = Quaternion.LookRotation(baseDirection);
                ShieldPushEffect.transform.rotation = r;

                ShieldPushEffect.Play();
            }


            //Send the message.
            GameObjectTracker.GetGOT().MeleeHits();
        }
        else
        {
            //if(xdir < InputBackBuffer)
            if (DefenseUnitSlot.CanDeflect && canShatter)
            {
                //Damage the target.
                t.Damage(MeleeDamage);

                //DefenseUnitSlot.ShieldShatterEffect.transform.localPosition = Tposition;
                //DefenseUnitSlot.ShieldShatterEffect.Play();
                ShatterEffect.transform.localPosition = Tposition;
                ShatterEffect.Play();

                //Play sound
                AudioPlayer.GetPlayer().PlaySound(ShatterSound);

                DidShatter = true;

                //Send the message.
                GameObjectTracker.GetGOT().MeleeShatter();
            }
        }

        //If we are performing a move, set can deflect to false to only do the move once per animation.
        //DefenseUnitSlot.CanDeflect = false;
    }
Пример #25
0
    public void OnMeleeCannon(Cannon c, float speed)
    {
        //We must be in deflect timing!
        if (!DefenseUnitSlot.CanDeflect)
        {
            //Whatever we want to register when the shield touches a target outside of the deflect window.

            //And return.
            return;
        }
        ;

        if (c == null)
        {
            return;
        }

        Rigidbody rbody = c.GetComponent <Rigidbody>();

        if (!rbody || rbody.isKinematic == true)
        {
            return;
        }

        //Force setting part.

        //We get the forward vector of the self.
        Vector3 baseDirection = reflectForce;

        baseDirection += myTransform.forward;
        baseDirection += myTransform.forward;


        //Scale the force by the mass and a set amount for now.
        baseDirection *= (rbody.mass * DeflectForceFactor);

        //Zero out the ball velocity.
        rbody.velocity = Vector3.zero;



        //Almost last but not least we call dont tax so you dont get the activation fee when you deflect a ball
        DefenseUnitSlot.DontTax();

        //Grab the x magnitude and test
        float xdir = Mathf.Abs(reflectForce.x);

        //If we have any direction but holdingback we add force to the ball and play sound.
        //if(reflectForce.z >= 0.0f)
        if (reflectForce.z >= InputBackBuffer)
        {
            //Play the sound file.
            if (MeleeSound)
            {
                AudioPlayer.GetPlayer().PlaySound(MeleeSound);
            }


            //Add the throwing force.
            rbody.AddForce(baseDirection, ForceMode.Force);

            if (ShieldPushEffect)
            {
                //Apply the effect on the target.
                Quaternion r = Quaternion.LookRotation(baseDirection);
                ShieldPushEffect.transform.rotation = r;

                ShieldPushEffect.Play();
            }


            //Send the message.
            GameObjectTracker.GetGOT().MeleeCannon();
        }
        else
        {
            //First we check if we have the right input to pick up the cannon.
            //Check if we dont have a cannon equipt then we equipt it!
            //if(xdir < InputBackBuffer)
            if (connectorcontroller.AttachCannon(c))
            {
                AudioPlayer.GetPlayer().PlaySound(PickUpCannonSound);

                //Send to the object tracking system.
                GameObjectTracker.GetGOT().CannonPickedUp();
                //DeactivateDefense

                //animation.Stop();
                //animation.Play(PickupCannonAnimation);
                GetComponent <Animation>().Play(PickupCannonAnimation, PlayMode.StopAll);

                //Set the temp guage to view.
                isTempVisible = true;
            }
        }



        //If we are performing a move, set can deflect to false to only do the move once per animation.
        //	DefenseUnitSlot.CanDeflect = false;
    }
Пример #26
0
 public void KillMe()
 {
     GameObjectTracker.GetGOT().MoneyLost(this);
     GemActive = false;
 }
    void OnCollisionEnter(Collision col)
    {
        //If we hit some walls
        if (col.gameObject.CompareTag("Wall") && MomentumDamage)
        {
            if (GetComponent <Rigidbody>().velocity.magnitude > 10.0f)
            {
                //print("BOOM!");

                //Play sound
                AudioPlayer.GetPlayer().PlaySound(HitSoundEffect);

                //Deal the damage
                Damage(TargetMomentumDamage);
            }
        }

        //If we hit some walls
        if (col.gameObject.CompareTag("Target"))
        {
            if (GetComponent <Rigidbody>().velocity.magnitude > 10.0f)
            {
                //print("BOOM!");

                //Play sound
                AudioPlayer.GetPlayer().PlaySound(HitSoundEffect);

                //Deal the damage
                Damage(SelfMomentumDamage);

                //Get the ball we collided with.
                Target t = col.gameObject.GetComponent <Target>();
                t.Damage(TargetMomentumDamage);
            }
        }


        ///If we hit a ball it should turn red now.
        if (col.gameObject.CompareTag("Ball"))
        {
            //Get the ball we collided with.
            Ball b = col.gameObject.GetComponent <Ball>();


            //Only look for active balls!
            if (b.IsActive() && b.GetBallSourceID() != Ball.BallSourceID.Netural)
            {
                //Damage
                Damage(b.DamageAmount);

                //audio.clip = HitSoundEffect;
                AudioPlayer.GetPlayer().PlaySound(HitSoundEffect);

                if (b.GetBallSourceID() == Ball.BallSourceID.Bot)
                {
                    //Send the message. Its about sending the message
                    GameObjectTracker.GetGOT().TargetHit();
                }


                //Pop the ball if it isnt shoot through.
                if (!b.IsShootThrough())
                {
                    b.Pop();
                }
            }
        }
    }    //OnCollisionEnter()
Пример #28
0
    protected void Initialize()
    {
        if (Collection)
        {
            //Create teh collection Particle Effect
            Collection = Instantiate(Collection) as ParticleSystem;


            Collection.transform.position = transform.position;
            Collection.transform.parent   = transform;
        }

        if (PreparingEffect)
        {
            //Create the effect
            PreparingEffect = Instantiate(PreparingEffect) as ParticleSystem;

            PreparingEffect.transform.parent        = transform;
            PreparingEffect.transform.localPosition = Vector3.zero;
        }

        //Get the connect Controller.
        connectorcontroller = GetComponentInChildren <CannonConnector>();
        if (connectorcontroller == null)
        {
            Debug.LogError("can't find cannon connector!!!!!!");
        }
        connectorcontroller.SetHost(gameObject);

        //All bad guys have hot cannons so nobody else picks up their cannons after they drop it.
        connectorcontroller.SetHotCannon(ForbiddenWeapons);


        //Get the smart beam
        Eyes = GameObjectTracker.GetGOT().World._objectView;

        Hands = GetComponent <BlackHole>();

        if (!Hands)
        {
            Debug.Log("No Black Hole created for enemy!");
        }

        //Set the ID
        timestamp = (int)Time.time;

        if (!Eyes)
        {
            Debug.LogError("No Smartbeam found on enemy! Please make sure to attach Smart Beam!");
        }

        CannonSpawner c = gameObject.GetComponentInChildren <CannonSpawner>();

        //Lets look for a spawner.
        if (c)
        {
            mySpawner = c;
        }

        myTransform = transform;
    }
Пример #29
0
    /// <summary>
    /// This funtion does the core checks for objects that all base bots shoudl check against.
    /// Things like always searching for cannons and picking them up if there is a free attachment slot and etc.
    /// </summary>
    void OnCollisionEnter(Collision col)
    {
        //Dont pull targets
        if (col.gameObject.CompareTag("CommandCenter"))
        {
            //This is test against shield.
            //Dont process this if shield isnt on.
            //Only melee CC with shield.
            if (!IsShieldActive())
            {
                return;
            }
            //Grab the target.
            Target t = col.gameObject.GetComponent <Target>();

            OnMelee(t, 18.0f, t.CanShatter);
        }



        if (col.gameObject.CompareTag("Target"))
        {
            //This is test against shield.
            //Dont process this if shield isnt on.
            //Only melee CC with shield.
            if (!IsShieldActive())
            {
                return;
            }

            Target t = col.gameObject.GetComponent <Target>();

            if (!t.IsDestroyed())
            {
                OnMelee(t, 50.0f, t.CanShatter);
            }
        }



        //Check if we collide with a cannon.
        if (col.gameObject.CompareTag("Cannon"))
        {
            Cannon c = col.gameObject.GetComponent <Cannon>();

            //check if we are holding shield.
            bool blocking = IsShieldActive();


            if (!IsOverHeated)
            {
                //Call attach for the cannon that we collide with.
                //Check first if we arent blocking then process the picking up of cannon code.
                if (!blocking)
                {
                    if (connectorcontroller.AttachCannon(c))
                    {
                        AudioPlayer.GetPlayer().PlaySound(PickUpCannonSound);

                        //Send to the object tracking system.
                        GameObjectTracker.GetGOT().CannonPickedUp();

                        GetComponent <Animation>().Play(PickupCannonAnimation, PlayMode.StopAll);


                        // when we attach we set the temperature, not just on collide
                        SetTemperature(MinTemperature);

                        //Set the temp guage to view.
                        isTempVisible = true;
                    }
                }
            }

            //Check for melee.
            if (blocking && DefenseUnitSlot.CanDeflect)
            {
                OnMeleeCannon(c, 45.0f);
            }
        }

        //Check if we collide with balls.
        if (col.gameObject.CompareTag("Ball"))
        {
            Ball b = col.gameObject.GetComponent <Ball>();


            if (IsShieldActive())
            {
                if (b.ID != Ball.BallSourceID.Netural && b.ID != Ball.BallSourceID.Hot && b.IsActive())
                {
                    OnBlockBall(b);
                    return;
                }

//				if(!b.IsActive())
//				{
//					PushBall(b);
//					return;
//
//				}
            }

            //We have to make sure we have a cannon attached to pick up a ball and we make sure sheild is not on.
            if (connectorcontroller.GetCannon())
            {
                if (b.GetBallSourceID() == Ball.BallSourceID.Enemy && !DefenseUnitSlot.IsActivated())
                {
//					AddHeat(b.DamageAmount);
////					print("Bot HIT!");
//

                    Damage(b.DamageAmount);
                }

                //Call attach for the cannon that we collide with.
                if (!IsShieldActive())
                {
                    if (connectorcontroller.GetCannon().PickupBall(b))
                    {
                        //Play the audio file.
                        AudioPlayer.GetPlayer().PlaySound(PickUpAmmo);

                        //Set teh ball source.
                        b.SetBallSourceID(Ball.BallSourceID.Bot);

                        //Play ball pick up effect.
                        if (BallCollection)
                        {
                            BallCollection.transform.position = b.transform.position;
                            BallCollection.Play();
                        }

                        if (!isAnimatingCannonPickup)
                        {
                            GetComponent <Animation>().Play(PickupBallAnimation);
                        }
                    }
                }

                if (connectorcontroller.IsCannonFull())
                {
                    AudioPlayer.GetPlayer().PlaySound(CannonFilled);
                }
            }
        }

        if (col.gameObject.CompareTag("Money"))
        {
            Money m = col.gameObject.GetComponent <Money>();

            //We pick up money.
            //Play the effect for picking up a ball.
            if (Collection && GameObjectTracker.instance.multiplierCount > 0)
            {
                //Play the collection animation.
                Collection.Play();
                AudioPlayer.GetPlayer().PlaySound(CollectSound);
            }


            //Do money adding logic here.
            GameObjectTracker.GetGOT().AddMoney(m);
        }

        if (col.gameObject.CompareTag("Wall"))
        {
            //WallCollideParticleEffect.gameObject.SetActive(true);
            WallCollideParticleEffect.Play();
            foreach (ContactPoint point in col.contacts)
            {
                WallCollideParticleEffect.transform.position = point.point;
                WallCollideParticleEffect.transform.forward  = point.normal;
                //Debug.DrawRay(point.point, point.normal);
            }
            //			WallCollideParticleEffect.transform.forward = col.transform.forward;
            //			WallCollideParticleEffect.transform.position = col.transform.position;
        }
    }
Пример #30
0
    // Use this for initialization
    void Awake()
    {
        //Set ourselves.
        Pandora = this;

        TimePaused = true;
//		Debug.LogError("Toybox Start");

        //Create an audioplayer if we dont ahve one.
        if (AudioPlayer.GetPlayer() == null)
        {
            SoundAudioPlayer = Instantiate(SoundAudioPlayer) as AudioPlayer;
        }

        //Lets just always create the toybox at normal scale.
        //Time.timeScale = timescalenormal;

        //Create the gem pot manager
        Rewards = Instantiate(Rewards) as GemPotManager;

        if (Controls)
        {
            //Little local storage to test if joystick has been found.
            bool found = false;

            //See if there is one in the scene first.
            foreach (Object o in FindObjectsOfType(typeof(Joystick)))
            {
                if (o.name == "TOYBOX_JOYSTICK")
                {
                    Controls = (Joystick)o;
                    found    = true;
                }
            }

            //If nothign was found then this is the first time.
            if (!found)
            {
                //Create and name.
                Controls      = Instantiate(Controls) as Joystick;
                Controls.name = "TOYBOX_JOYSTICK";

                //Keep us alive just because man.
                DontDestroyOnLoad(Controls.gameObject);
            }
        }


        ///////// Bot Creation ///////

        //Create the command center.
        CommandCenter_01 = Instantiate(CommandCenter_01) as CommandCenter;

        if (!CreateCommandCenter)
        {
            CommandCenter_01.gameObject.SetActive(false);
        }

        //Create the bot
        Bot_01 = Instantiate(Bot_01) as BasicBot;


        //Create the shield
        BotShield_01 = Instantiate(BotShield_01) as SimpleShield;

        //Attach the shield to the bot.

        Bot_01.SetDefenseUnit(BotShield_01);

        //Trigger the spawns and store them in the cannon list.



        ///////// Bot Creation ///////



        /////////Scene Setup//////////

//		Camera_01 = GameObjectTracker.instance.GameCamera;
//
//
//		if(Camera_01)
//		{
//			//Set teh camera to look at the bot.
//			Camera_01.SetBotToFollow(Bot_01);
//
//			//Set teh game camera as the current game camera.
//			Camera.SetupCurrent(Camera_01.MyCamera);
//		}
//
        //Create the ball stack and yeah...
        SceneBallStack = Instantiate(SceneBallStack) as BallStack;

        /////////Scene Setup//////////


        //Create the NGUI last

        if ((FUIHud && createFUI) && ActivityManager.Instance == null)
        {
            FUIHud = Instantiate(FUIHud) as UIRoot;

            //What happens if we dont destroy?
            DontDestroyOnLoad(FUIHud.gameObject);
        }
        else
        {
            //If the activitiy manager is alrady crated and is not active, then we simply activate.
            if (ActivityManager.Instance.SetActive == false)
            {
                ActivityManager.Instance.SetActive = true;

                //here we should activate the gameplay world as well.
                GameObjectTracker.GetGOT().World.gameObject.SetActive(true);
            }
        }


        if (fui3DManager && createFui3D)
        {
            fui3DManager = Instantiate(fui3DManager) as FUI3DManager;
        }

        if (MyPowerUpSpawner == null)
        {
            Debug.LogError("No powerup spawner in testgame");
        }
//		Debug.LogError("Toybox End");
    }