Example #1
0
        private void addProductToolStripMenuItem_Click(object sender, EventArgs e)
        {
            New_Item new_Item = new New_Item();

            new_Item.MdiParent     = this;
            new_Item.StartPosition = FormStartPosition.CenterScreen;
            new_Item.Show();
        }
Example #2
0
    //This will load the saved level.
    void Load_Level_Save()
    {
        //load the test level. This will be changed when the game is final and we have multiple levels.
        TextAsset Level = Resources.Load("Made_Levels/Test_Level") as TextAsset;
        //Debug.Log(Level.text);

        //test
        //GameObject.Find("Test").GetComponent<SpriteRenderer>().sprite = Instantiate(Resources.Load(Current_Strings.Texture_Tower_Ruby)) as Sprite;//Main_Script.Locked_Gems.Locked_Gem_List[0].sp_Tower_Sprite;
        //Tower Test_Tower = new Tower();
        //GameObject New_Test = Main_Script.Create_New_Tower("Ruby");
        //New_Test.transform.position = new Vector3(0, 0);

        //height/width and spaces stored here to create the map after we have all the information.
        int  t_Width         = 0;
        int  t_Height        = 0;
        bool b_Shared_Energy = false;
        bool b_Shared_Allies = false;

        //This is the theme for the background of the map.
        string s_Theme = "Default";


        //All the level string items.
        string[] Level_Items = Level.text.Split('\n');
        //Going through all the level items.
        for (int i = 0; i < Level_Items.Length; i++)
        {
            //THE VARIABLES THAT NEED TO BE SET.
            if (Level_Items[i].Contains("Name("))
            {
                Main_Script.s_Level_Name = Level_Items[i].Split('(')[1];
            }
            else if (Level_Items[i].Contains("Starting Energy("))
            {
                Main_Script.f_Energy = float.Parse(Level_Items[i].Split('(')[1]);
            }
            else if (Level_Items[i].Contains("Shared Enery("))
            {
                b_Shared_Energy = bool.Parse(Level_Items[i].Split('(')[1]);
            }
            else if (Level_Items[i].Contains("Starting HP("))
            {
                Main_Script.f_HP = int.Parse(Level_Items[i].Split('(')[1]);
            }
            else if (Level_Items[i].Contains("Max HP("))
            {
                Main_Script.i_Max_HP = int.Parse(Level_Items[i].Split('(')[1]);
            }
            else if (Level_Items[i].Contains("Shared Allies("))
            {
                b_Shared_Allies = bool.Parse(Level_Items[i].Split('(')[1]);
            }
            else if (Level_Items[i].Contains("Grid X("))
            {
                t_Width = int.Parse(Level_Items[i].Split('(')[1]);
            }
            else if (Level_Items[i].Contains("Grid Y("))
            {
                t_Height = int.Parse(Level_Items[i].Split('(')[1]);
            }
            else
            {
                //OBJECTS THAT NEED TO BE MADE/SET
                if (Level_Items[i].Contains("Lock Gem("))
                {
                    //name,locked,cost
                    string Arg1 = Level_Items[i].Split('(')[1].Split(',')[0];
                    string Arg2 = Level_Items[i].Split('(')[1].Split(',')[1];
                    string Arg3 = Level_Items[i].Split('(')[1].Split(',')[2];

                    //search current locked gem list and set it up.
                    for (int j = 0; j < Main_Script.Locked_Gems.Locked_Gem_List.Count; j++)
                    {
                        if (Main_Script.Locked_Gems.Locked_Gem_List[j].Name == Arg1)
                        {
                            Main_Script.Locked_Gems.Locked_Gem_List[j].i_Cost   = int.Parse(Arg3);
                            Main_Script.Locked_Gems.Locked_Gem_List[j].b_Locked = bool.Parse(Arg2);
                        }
                    }
                }
                if (Level_Items[i].Contains("Tower("))
                {
                    // Tower_List[i].Tower_Name + "," + Tower_List[i].Tower_Level + "," + Tower_List[i].Tower_Power + "," + Tower_List[i].Tower_Speed + "," + Tower_List[i].Tower_Range + "," + Tower_List[i].Tower_Points;
                    string Arg1 = Level_Items[i].Split('(')[1].Split(',')[0];
                    int    Arg2 = int.Parse(Level_Items[i].Split('(')[1].Split(',')[1]);
                    int    Arg3 = int.Parse(Level_Items[i].Split('(')[1].Split(',')[2]);
                    int    Arg4 = int.Parse(Level_Items[i].Split('(')[1].Split(',')[3]);
                    int    Arg5 = int.Parse(Level_Items[i].Split('(')[1].Split(',')[4]);
                    int    Arg6 = int.Parse(Level_Items[i].Split('(')[1].Split(',')[5]);

                    //create the tower, update the stats and move it.
                    GameObject go_New_Tower = Main_Script.Create_New_Tower(Arg1);



                    //tower not null, we add it to the list and move it to invintory.
                    if (go_New_Tower != null)
                    {
                        Tower New_Tower = go_New_Tower.GetComponent <Tower>();
                        //Sets up the tower.
                        New_Tower.i_Level           = Arg2;
                        New_Tower.f_Power_Amount    = Arg3;
                        New_Tower.f_Speed_Amount    = Arg4;
                        New_Tower.f_Range_Amount    = Arg5;
                        New_Tower.i_Spending_Points = Arg6;

                        Main_Script.Tower_List.Add(go_New_Tower);
                        go_New_Tower.GetComponent <Tower>().Move_To_Invintory(true);
                    }
                }

                //Enemy_List[i].Enemy_Name + "," + Enemy_List[i].Enemy_Wave_Number + "," + Enemy_List[i].Enemy_HP + "," + Enemy_List[i].Enemy_Speed + "," + Enemy_List[i].Enemy_Power + "," + Enemy_List[i].Enemy_Amount + "," + Enemy_List[i].Enemy_Start_After + "," + Enemy_List[i].Enemy_Reward_Single + "," + Enemy_List[i].Enemy_Reward_Wave + "," + Enemy_List[i].Enemy_Mod;
                if (Level_Items[i].Contains("Enemies("))
                {
                    string Arg1  = Level_Items[i].Split('(')[1].Split(',')[0];
                    int    Arg2  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[1]);
                    int    Arg3  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[2]);
                    int    Arg4  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[3]);
                    int    Arg5  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[4]);
                    int    Arg6  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[5]);
                    int    Arg7  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[6]);
                    int    Arg8  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[7]);
                    int    Arg9  = int.Parse(Level_Items[i].Split('(')[1].Split(',')[8]);
                    string Arg10 = Level_Items[i].Split('(')[1].Split(',')[9];

                    //create the enemy and add it to the main scripts list.
                    //GameObject New_Temp = new GameObject();
                    //New_Temp.transform.position = new Vector3(-500, -500);
                    //New_Temp.AddComponent<Enemy>();

                    //Enemy New_Enemy = New_Temp.GetComponent<Enemy>();
                    Enemy New_Enemy = new Enemy();
                    //set up the new enemy as a spawner.
                    New_Enemy.Set_Enemy(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, true);

                    //set up the bullet prefab location.
                    New_Enemy.s_Bullet_Prefab = Current_Strings.Prefab_Attacks_Location + Arg1.Split(' ')[0];
                    //Debug.Log(New_Enemy.s_Bullet_Prefab);

                    //might need to create the item so it's not null and have it off screen.
                    New_Enemy.i_Location_In_Spawn_Array = Main_Script.Add_To_Enemy_Spawns(New_Enemy); // Main_Script.Enemy_Spawns.Count;
                                                                                                      //Main_Script.Enemy_Spawns.Add(New_Enemy);

                    //this is for endless mode if it's used. since not sure at this point cause still loading the file we just assume it is.
                    if (New_Enemy.i_Wave_Number > Main_Script.f_Endless_Count)
                    {
                        Main_Script.f_Endless_Count = (float)New_Enemy.i_Wave_Number;
                    }
                    Main_Script.Endless_Enemy_List.Add(New_Enemy);
                }
            }
        }

        //make the map with the items in it. We do it a longer way since only done once and will prevent out of index errors.
        GameObject[,] Space_Array = new GameObject[t_Width, t_Height];

        //Can add in the map items now.
        for (int i = 0; i < Level_Items.Length; i++)
        {
            //"Field Object X/Y(" + All_Field_Spots[x, y].transform.GetChild(i).name + "," + x + "," + y;
            if (Level_Items[i].Contains("Field Object X/Y("))
            {
                string Arg1 = Level_Items[i].Split('(')[1].Split(',')[0];
                int    Arg2 = int.Parse(Level_Items[i].Split('(')[1].Split(',')[1]);
                int    Arg3 = int.Parse(Level_Items[i].Split('(')[1].Split(',')[2]);

                GameObject New_Item;

                //ensure the range is acceptable and the space is empty.
                if (Arg2 < t_Width && Arg2 > -1 && Arg3 < t_Height && Arg3 > -1)
                {
                    if (Space_Array[Arg2, Arg3] == null)
                    {
                        if (Arg1.Contains("Decoration"))
                        {
                            New_Item = Instantiate(Resources.Load(Current_Strings.Prefab_MI_Decorations_Location + Arg1)) as GameObject;
                            New_Item.AddComponent <Map_Deco>();
                            New_Item.GetComponent <Map_Deco>().Deco_Setup(Arg1, Arg2, Arg3);
                            Space_Array[Arg2, Arg3] = New_Item;
                            New_Item.tag            = Current_Strings.Tag_Decoration;
                        }
                        else if (Arg1.Contains("Start_Point"))
                        {
                            New_Item      = Instantiate(Resources.Load(Current_Strings.Prefab_MI_Spots_Start)) as GameObject;
                            New_Item.name = Current_Strings.Name_Map_Start;
                            New_Item.tag  = Current_Strings.Tag_Start_Spawn;
                            New_Item.AddComponent <Map_Start>();
                            New_Item.GetComponent <Map_Start>().Map_Start_Setup(Current_Strings.Name_Map_Start, Arg2, Arg3);
                            Space_Array[Arg2, Arg3] = New_Item;
                        }
                        else if (Arg1.Contains("Name_Path_Maker"))
                        {
                            New_Item      = Instantiate(Resources.Load(Current_Strings.Prefab_MI_Spots_Temple)) as GameObject;
                            New_Item.name = Current_Strings.Name_Map_Temple;
                            New_Item.tag  = Current_Strings.Tag_Finish_Temple;
                            New_Item.AddComponent <Map_Temple>();
                            New_Item.GetComponent <Map_Temple>().Map_Temple_Setup(Current_Strings.Name_Map_Temple, Arg2, Arg3);
                            Space_Array[Arg2, Arg3] = New_Item;
                        }
                        else if (Arg1.Contains("d_") || Arg1.Contains("w_") || Arg1.Contains("s_") || Arg1.Contains("a_"))
                        {
                            //Paths are special since going to be a few depending on what theme is picked.
                            New_Item = Instantiate(Resources.Load(Current_Strings.Prefab_MI_Path_Template)) as GameObject;
                            New_Item.AddComponent <Map_Path>();
                            New_Item.GetComponent <Map_Path>().Map_Path_Setup(Arg1, Arg2, Arg3);
                            Space_Array[Arg2, Arg3] = New_Item;
                            New_Item.tag            = Current_Strings.Tag_Path;
                            //Might now work will need to check.
                            Main_Script.Path_List.Add(New_Item.GetComponent <Map_Path>());
                        }
                    }
                    //Map_Deco New_Deco = new Map_Deco();
                }
            }
        }

        //PATH CORNERS here we go through and set up the path corners as needed.
        for (int j = 0; j < Main_Script.Path_List.Count; j++)
        {
            for (int k = 0; k < Main_Script.Path_List.Count; k++)
            {
                if (Main_Script.Path_List[j].Path_Number == Main_Script.Path_List[k].Path_Number - 1)
                {
                    Main_Script.Path_List[k].Set_Corner_Sprite(Main_Script.Path_List[j].Name + Main_Script.Path_List[k].Name);
                }
            }
        }


        //Fill the rest of the spots with blanks.
        Transform Map_Parent_Trans = GameObject.Find(Current_Strings.Name_Map_Parent).transform;
        //parent x - (width * box size / 2) + .5 * box size
        float t_x_Offset = Map_Parent_Trans.transform.position.x - (t_Width * f_Default_Box_Size / 2) + (f_Default_Box_Size / 2);
        float t_y_Offset = Map_Parent_Trans.transform.position.y - (t_Height * f_Default_Box_Size / 2) + (f_Default_Box_Size / 2);

        for (int x = 0; x < t_Width; x++)
        {
            for (int y = 0; y < t_Height; y++)
            {
                if (Space_Array[x, y] == null)
                {
                    GameObject New_Empty_Spot = Instantiate(Resources.Load(Current_Strings.Prefab_MI_Map_Space)) as GameObject;
                    New_Empty_Spot.GetComponent <Map_Space>().X_Spot = x;
                    New_Empty_Spot.GetComponent <Map_Space>().Y_Spot = y;
                    Space_Array[x, y] = New_Empty_Spot;
                }

                //space/move them right here and set parent.
                Space_Array[x, y].transform.position = new Vector2(t_x_Offset + (x * f_Default_Box_Size), (t_y_Offset + (y * f_Default_Box_Size)) * -1);
                Space_Array[x, y].transform.parent   = Map_Parent_Trans;
            }
        }

        //Set the array to the main script.
        Main_Script.Map_Spaces = Space_Array;



        //Add in the background to size for the theme used. added more just so it covers the whole map no matter what.
        int t_Total_W = (int)(t_Width * f_Default_Box_Size / 10.24f) + 16;
        int t_Total_H = (int)(t_Height * f_Default_Box_Size / 10.24f) + 16;

        int i_Number_For_Theme = 1;

        for (int i = 0; i < t_Total_W; i++)
        {
            for (int j = 0; j < t_Total_H; j++)
            {
                //create the background item.
                GameObject New_Background = Instantiate(Resources.Load(Current_Strings.Prefab_Theme_Location + s_Theme + "/" + s_Theme + "_" + i_Number_For_Theme)) as GameObject;
                float      Offset_x       = (((t_Total_W * 10.24f) / 2) * -1) + 5.12f;
                float      Offset_y       = (((t_Total_H * 10.24f) / 2) * -1) + 5.12f;
                New_Background.transform.position = new Vector2(Offset_x + (10.24f * i), Offset_y + (10.24f * j));
                New_Background.transform.parent   = Map_Parent_Trans;
            }
        }


        //Sets the shared items to use.
        if (b_Shared_Energy)
        {
            //WILL ADD IN AFTER WE HAVE THE MAIN MENU SAVING AND PROFILE SAVING DONE.else if (Level_Items[i].Contains("Starting Energy("))
        }
        if (b_Shared_Allies)
        {
            //WILL ADD IN AFTER WE HAVE THE MAIN MENU SAVING AND PROFILE SAVING DONE.else if (Level_Items[i].Contains("Starting Energy("))
        }


        //setting up the pan bounds
        Main_Script.f_x_Bound = (t_Width * f_Default_Box_Size) / 2;
        Main_Script.f_y_Bound = (t_Height * f_Default_Box_Size) / 2;


        //after loading the level we check if it's endless and if so then we load up like 30x endless waves.
        if (Main_Script.b_Endless_Mode)
        {
            for (int w = 0; w < 30; w++)
            {
                Main_Script.Add_For_Endless();
            }
        }
    }
Example #3
0
        public ActionResult NewItems()
        {
            // get categories
            List <Item_type> obj  = new List <Item_type>();
            List <Karigar>   kobj = new List <Karigar>();
            List <Saleman>   sobj = new List <Saleman>();
            // New_Item tobj = new New_Item();
            New_Item Parent       = new New_Item();
            string   karigarqery  = "Select * from [Karigar]";
            string   itemquery    = "Select * from [Item_type]";
            string   salemanquery = "Select * from [Saleman]";
            string   tagquery     = "SELECT TOP 1 [I_tag_no] FROM [Items] ORDER BY [I_id] DESC";

            using (SqlConnection con = new SqlConnection(cs))
            {
                using (SqlCommand cmd = new SqlCommand(itemquery))
                {
                    cmd.Connection = con;
                    // opening connection
                    con.Open();
                    cs = con.State.ToString();
                    SqlDataReader sdr = cmd.ExecuteReader();
                    while (sdr.Read())
                    {
                        Item_type np = new Item_type();
                        np.I_type_id   = (int)sdr["I_type_id"];
                        np.I_type_name = (string)sdr["I_type_name"];
                        obj.Add(np);
                    }
                    con.Close();
                }

                using (SqlCommand cmd = new SqlCommand(salemanquery))
                {
                    cmd.Connection = con;
                    // opening connection
                    con.Open();
                    cs = con.State.ToString();
                    SqlDataReader sdr = cmd.ExecuteReader();
                    while (sdr.Read())
                    {
                        Saleman snp = new Saleman();
                        snp.S_id   = (int)sdr["S_id"];
                        snp.S_name = (string)sdr["S_name"];
                        sobj.Add(snp);
                    }
                    con.Close();
                }

                using (SqlCommand cmd = new SqlCommand(karigarqery))
                {
                    cmd.Connection = con;
                    // opening connection
                    con.Open();
                    cs = con.State.ToString();
                    SqlDataReader sdr = cmd.ExecuteReader();
                    while (sdr.Read())
                    {
                        Karigar knp = new Karigar();
                        knp.K_id   = (int)sdr["K_id"];
                        knp.K_name = (string)sdr["K_name"];
                        kobj.Add(knp);
                    }
                    con.Close();
                }

                using (SqlCommand cmd = new SqlCommand(tagquery))
                {
                    cmd.Connection = con;
                    con.Open();
                    cs = con.State.ToString();
                    SqlDataReader tdr = cmd.ExecuteReader();
                    New_Item      tnp = new New_Item();
                    if (tdr.Read())
                    {
                        tnp.I_tag_no = (int)tdr["I_tag_no"] + 1;
                        temptag      = tnp.I_tag_no.ToString();
                    }
                    else
                    {
                        tnp.I_tag_no = 5000;
                        temptag      = tnp.I_tag_no.ToString();
                    }
                    Parent.I_tag_no = tnp.I_tag_no;
                    con.Close();
                }
            }
            Parent.Iobj = obj;
            Parent.Kobj = kobj;
            Parent.Sobj = sobj;

            return(View(Parent));
        }