Beispiel #1
0
        public void StartBuild()
        {
            //If not already building anything and the queue count is above 0 , start to build!!
            if (m_currentBuildingThing == null && m_buildingQueue.Count > 0 && m_SoL != null)
            {
                //Creates an empty thing first
                Thing f_temp = null;
                //Switch checks what type it is to be built
                switch (m_buildingQueue.Dequeue())
                {
                //If it's Cube
                case ThingType.C_Cube:
                    //f_temp is now a cube!
                    f_temp = m_player.m_thingsAssets.CreateCube(m_builder.m_currentposition);
                    break;
                }

                //returns true if harvesting was possible
                if (m_SoL.Harvest())
                {
                    //If player has supply to add the cube
                    if (f_temp != null)
                    {
                        //Shall now build it!
                        m_currentBuildingThing = f_temp;
                        //Calls the player function to add a currentlyBuildingThing to it's lists and supply and what not!
                        if (m_player.CanAddUnit(m_currentBuildingThing))
                        {
                            m_addedWithSupply = true;
                            m_player.AddSupply(GetSupplyValue());
                        }
                        else
                        {
                            m_addedWithSupply = false;
                        }
                    }
                }
                else
                {
                    switch (m_builder.m_type)
                    {
                    case ThingType.C_Extractor:
                        //(m_builder as Extractor).m_SoL = null;
                        //gotta destroy all references or it still exists in ze program
                        m_SoL = null;
                        break;
                    }

                    //Removes itself from the list of thingBuilders as it can no longer build anything!
                    //m_player.RemoveThingBuilder(m_builder);
                }
            }//End if (currentbuildthing == null && m_buildQueue > 0 && m_sol != null
        }
Beispiel #2
0
        public void Cancel(Player a_player, Map a_map)
        {
            foreach (BuildingObject bo in a_player.m_buildObjects)
            {
                if (bo.m_object == this)
                {
                    bo.CancelBuild(a_player, a_map);
                    break;
                }
            }

            m_SoL.FreeSoL();
            m_SoL = null;
        }
Beispiel #3
0
        public CSBuilder(Player a_player, Thing a_builder, SoL a_SoL, Map a_map, PathFinder a_pathfinder)
        {
            m_player = a_player;

            m_map = a_map;

            m_pathfinder = a_pathfinder;

            m_builder = a_builder;

            m_player.AddThingBuilder(m_builder);

            m_SoL = a_SoL;
        }
Beispiel #4
0
 public static CSBuilder CreateNewCSBuilder(Player a_player, Thing a_builder, SoL a_sol, Map a_map, PathFinder a_pathfinder)
 {
     return(new CSBuilder(a_player, a_builder, a_sol, a_map, a_pathfinder));
 }
Beispiel #5
0
 public void SetSoL(SoL a_sol)
 {
     m_SoL = a_sol;
     m_SoL.TakeSoL();
 }
Beispiel #6
0
 public Extractor(byte a_id, Model a_model, int a_hp, int a_maxHP, Vector3 a_position, SoL a_SoL, addUnderAttackPosition a_Function)
     : this(a_id, a_model, a_hp, a_maxHP, a_position, a_Function)
 {
     SetSoL(a_SoL);
 }
Beispiel #7
0
        //Draws a selected units stats
        private void DrawInfo(SpriteBatch a_spriteBatch, GameAssets a_gameAssets, ModelClasses.Player a_player)
        {
            //TEMP to see the info area  - I c wut u did thar /Tiger!
            a_spriteBatch.Draw(a_gameAssets.m_button, m_infoArea, Color.Violet);

            if (a_player.m_focusedTarget != null)
            {
                //Format text
                string f_info = string.Format("HP: {0}/{1}\n",
                                              a_player.m_focusedTarget.HP,
                                              a_player.m_focusedTarget.m_maxHP);

                if (a_player.m_focusedTarget.m_builtTimer < a_player.m_focusedTarget.m_requiredBuildTime)
                {
                    m_buildProgress.SetProgress(a_player.m_focusedTarget.m_builtTimer / a_player.m_focusedTarget.m_requiredBuildTime);

                    string f_buildingInfo = string.Format("{0:0.0} / {1:0.0} {2:0.0}% \nBuilding: {3}", a_player.m_focusedTarget.m_builtTimer,
                                                          a_player.m_focusedTarget.m_requiredBuildTime, m_buildProgress.Percentage * 100, GetUnitName(a_player.m_focusedTarget.m_type));

                    a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_rectangle, Color.DarkGray);
                    a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_progressArea, Color.Green);

                    a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_buildingInfo, m_buildInfo, Color.White);
                }

                //Special hud info for special types, like extractor needs to write how many sols it has left
                switch (a_player.m_focusedTarget.m_type)
                {
                case ModelClasses.Units.ThingType.C_Extractor:
                    Extractor f_tempExtractor = (Extractor)a_player.m_focusedTarget;
                    if (f_tempExtractor.m_SoL != null && f_tempExtractor.m_SoL.m_resources >= 0)
                    {
                        f_info += "SoLs: " + f_tempExtractor.m_SoL.m_resources;
                    }
                    else
                    {
                        f_info += "SoLs: Depleted";
                    }
                    break;
                }

                if (a_player.m_focusedTarget.m_buildBehavior != null)
                {
                    if (a_player.m_focusedTarget.m_buildBehavior.IsBuilding())
                    {
                        ThingType f_type = a_player.m_focusedTarget.m_buildBehavior.GetBuildingType();
                        float     a_requiredBuildTime = a_player.m_thingsAssets.GetThing(f_type).m_requiredBuildTime;

                        m_buildProgress.SetProgress(a_player.m_focusedTarget.m_buildBehavior.GetBuildTimer() / a_requiredBuildTime);

                        string f_buildingInfo = string.Format("Building: {0}\n{1:0.0} / {2:0.0} {3:0.0}% ", HUD.GetUnitName(f_type), a_player.m_focusedTarget.m_buildBehavior.GetBuildTimer(), a_requiredBuildTime, m_buildProgress.Percentage * 100);

                        a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_rectangle, Color.DarkGray);
                        a_spriteBatch.Draw(a_gameAssets.m_button, m_buildProgress.m_progressArea, Color.Green);

                        a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_buildingInfo, m_buildInfo, Color.White);
                    }

                    if (a_player.m_focusedTarget.m_buildBehavior is ModelClasses.BehaviorInterfaces.StandardBuild)
                    {
                        f_info += "Workers: " + a_player.m_focusedTarget.m_buildBehavior.GetSacrificeCount();
                    }
                }

                //Checks if the attack behavior is null or not! to write out that data!
                if (a_player.m_focusedTarget.m_attackBehavior != null)
                {
                    f_info += string.Format("Damage: {0} \nRange: {1}", a_player.m_focusedTarget.m_attackBehavior.GetDamage(), a_player.m_focusedTarget.m_attackBehavior.GetAttackRange());
                }

                if (a_player.m_selectedThings.Count > 1)
                {
                    //Should have draw portraits or something here instead, just temp stuff.. I wanna see selected info!!!
                    //Extremely temp code
                    if (a_player.m_focusedTarget.m_isUnit)
                    {
                        string f_selectedInfo = string.Format("Units selected: {0}", a_player.m_selectedThings.Count);
                        a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_selectedInfo, new Vector2(m_infoAreaPadded.X + m_infoArea.Width * 0.5f, m_area.Bottom - 45), Color.White);
                    }
                    else
                    {
                        string f_selectedInfo = string.Format("Buildings selected: {0}", a_player.m_selectedThings.Count);
                        a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_selectedInfo, new Vector2(m_infoAreaPadded.X + m_infoArea.Width * 0.5f, m_area.Bottom - 45), Color.White);
                    }
                }

                //Draw text
                a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_info, m_infoAreaPadded, Color.White);
            }
            else if (a_player.m_selectedWorldObject != null)
            {
                if (a_player.m_selectedWorldObject.m_type == WorldObjectType.SoL)
                {
                    //Creates a sol variable to access the SoL variables
                    SoL f_SoL = (SoL)a_player.m_selectedWorldObject;

                    string f_info = string.Format("SoLs: {0}", f_SoL.m_resources);

                    a_spriteBatch.DrawString(a_gameAssets.m_normalFont, f_info, m_infoAreaPadded, Color.White);
                }
            }
        }