Example #1
0
    public void updateDisplay(Ship_Class ship, int colorIndex)
    {
        this.ship = ship;

        switch (ship.getShipType())
        {
        case "Frigate":
            shipInfoImage.sprite = frigateImages[colorIndex];
            break;

        case "Cruiser":
            shipInfoImage.sprite = cruiserImages[colorIndex];
            break;

        case "Battleship":
            shipInfoImage.sprite = battleshipImages[colorIndex];
            break;

        case "Destroyer":
            shipInfoImage.sprite = destroyerImages[colorIndex];
            break;

        case "Dreadnought":
            shipInfoImage.sprite = dreadnoughtImages[colorIndex];
            break;
        }
        shipInfoImage.GetComponent <Image>().SetNativeSize();
        Color temp = shipInfoImage.GetComponent <Image>().color;

        temp.a = 1f;
        shipInfoImage.GetComponent <Image>().color = temp;

        shipInfoText.text = ship.getShipType();
    }
Example #2
0
    public void ShipStacker(Vector3 pos)
    {
        stackerRunning = true;

        Ship_Class[] temp = GameObject.FindObjectsOfType <Ship_Class>();

        int j = 0;                                            //Number of ships in that location

        Ship_Class[] shipStack = new Ship_Class[temp.Length]; //Ships in stack

        foreach (Ship_Class i in temp)                        //put ships into an array
        {
            if (pos == i.pos)
            {
                shipStack[j] = i;
                //print("Overlap "+shipStack[j].name);//what ship is overlapped
                j++;
            }
        }
        foreach (Ship_Class i in shipStack)//ignore
        {
            if (i != null)
            {
                //print("Ship " + i.name);//Name of ship overlapped
                i.shipsInStack = shipStack;
            }
        }

        stackerRunning = false;
    }
    public void GetAttackerShip(int place)
    {
        switch (place)
        {
        case 0:
            print(good[place].name);
            attacker = good[place];
            spota    = place;
            // print(aone);
            if (!Switchsides)
            {
                aone.interactable = false;
            }

            break;

        case 1:
            attacker = good[place];
            spota    = place;
            if (!Switchsides)
            {
                atwo.interactable = false;
            }
            break;

        case 2:
            attacker = good[place];
            spota    = place;
            // print(aone);
            if (!Switchsides)
            {
                athree.interactable = false;
            }
            break;

        case 3:
            attacker = good[place];
            spota    = place;
            // print(aone);
            if (!Switchsides)
            {
                afour.interactable = false;
            }
            break;

        case 4:
            attacker = good[place];
            spota    = place;
            // print(aone);
            if (!Switchsides)
            {
                afive.interactable = false;
            }
            break;
        }
    }
    public void GetDefenderShip(int place)
    {
        switch (place)
        {
        case 0:
            //print(bad[place].name);
            defender = bad[place];
            spotd    = place;
            if (Switchsides)
            {
                bone.interactable = false;
            }
            break;

        case 1:
            defender = bad[place];
            spotd    = place;
            if (Switchsides)
            {
                btwo.interactable = false;
            }
            break;

        case 2:
            defender = bad[place];
            spotd    = place;
            if (Switchsides)
            {
                bone.interactable = false;
            }
            break;

        case 3:
            defender = bad[place];
            spotd    = place;
            if (Switchsides)
            {
                bone.interactable = false;
            }
            break;

        case 4:
            defender = bad[place];
            spotd    = place;
            if (Switchsides)
            {
                bone.interactable = false;
            }
            break;
        }
    }
Example #5
0
    public void clearDisplay()
    {
        if (ship != null)
        {
            ship.selected = false;
        }
        this.ship            = null;
        shipInfoImage.sprite = emptyImage;
        Color temp = shipInfoImage.GetComponent <Image>().color;

        temp.a = 0f;
        shipInfoImage.GetComponent <Image>().color = temp;
        shipInfoText.text = "";
    }
Example #6
0
    // Start is called before the first frame update
    void Start()
    {
        ship_id = 10;

        Ship_Class sc1 = new Ship_Class(1, "ワンダー級", "DD", 2000, 20, 30, 100, 300);
        Ship_Class sc2 = new Ship_Class(2, "オットー級", "AK", 350, 50, 10, 600, 500);

        List_ship_class.Add(sc1);
        List_ship_class.Add(sc2);


        //ポート画面を更新。
        port_ui.GetComponent <Port_Panel_ui_controller>().Deploy_Calsses(List_ship_class);
        port_ui.GetComponent <Port_Panel_ui_controller>().Deploy_ship_in_pool(List_ships_in_port);

        //


        //建造。してポートにつなげる。
        //AddShiptoPort(CreateShip(ship_id, "ティルピッツ", false, List_ship_class[0]));
    }
Example #7
0
    //個別のシップをインスタンス化する処理。実際には建造に相当する処理。
    public void CreateShip(string this_ship_name, bool enemy_flg, Ship_Class sc)
    {
        if (RM.GetComponent <ResourceManager>().Check_enough_money(sc.money_to_make))
        {
            //艦船を作るときにお金を減らす。
            //RM.GetComponent<ResourceManager>().money -= sc.money_to_make;
            RM.GetComponent <ResourceManager>().UseMoney(sc.money_to_make);

            //インスタンス化する処理。
            Ship_test n_ship = new Ship_test
                                   (ship_id,
                                   this_ship_name + ship_id.ToString(),
                                   sc.ship_class_name,
                                   enemy_flg,
                                   sc.max_hp,
                                   sc.max_hp,
                                   sc.atk_point,
                                   sc.agility,
                                   sc.reward_money,
                                   sc.ship_type
                                   );

            ship_id += 1;

            Debug.Log(ship_id + "だよ");
            Debug.Log(n_ship.ship_id + "だよ");


            //軍港に配置。
            List_ships_in_port.Add(n_ship);

            //UI更新
            PortShiplistUpdate();
        }
        else
        {
            //お金ないでつ。
            Debug.Log("お金ないです");
        }
    }
Example #8
0
 public void updateShipInfo(Ship_Class ship, int colorIndex)
 {
     shipInfo.updateDisplay(ship, colorIndex);
 }
    // Engine -- ingore
    //Armour -- TARGET FIRST
    //Beam -- 1 beam = 1 attack,2 beam = 2 attack etc
    //Sheild -- protects againist lasers 50% of blocking
    //Missile -- 1 missle = 1 attack, etc
    //Coloization Module -- ingore
    //Anti-Missile -- protects againist missiles 50% of blocking
    //System Repair Module --write last check GDD

    //do math after both sides attack



    public void Update()
    {
        //print("update combat");
        //print(combat);
        if (combat)
        {
            //print(Switch);
            if (attacker != null && defender != null && Switchsides == false)//Attacker Turn(Initante Combat)
            {
                print("Attacker Turn");
                enableattackerbuttons();
                enabledefenderbuttons();
                FindWeapons(attacker.parts_list);
                FindDefense(defender.parts_list);
                print(numofbeam + "  " + numofmissle + "  " + numofsheild + "   " + numofantimissle);
                if (numofbeam == 0 && numofmissle == 0)
                {
                    allzeros1 = true;
                }
                int weaps = numofbeam + numofmissle;
                for (int i = 0; i < weaps; i++)
                {
                    if (numofbeam != 0)//check if they have a beam attack
                    {
                        numofbeam--;
                        if (Random.Range(0, 100) <= 50 /* || true*/) //chance of attacking, if its less then 50
                        {
                            if (numofsheild != 0)                    //do they have sheild
                            {
                                numofsheild--;
                                if (Random.Range(0, 100) >= 50)//50% of blocking, if its more then 50 then block
                                {
                                    print("Damage was blocked");
                                }
                                else//attacked
                                {
                                    print("Damage was done");
                                    if (numofarmor != 0)//armor has to be DESTROYED
                                    {
                                        print("armor is under attack");
                                        Findarmor(defender.parts_list);
                                        deflist[spotd, loc]--; //minus 1 health to armor
                                        if (deflist[spotd, loc] == 0)
                                        {
                                            numofarmor--;
                                        }
                                    }
                                    else
                                    {
                                        print("Compoents under attack");
                                        number = Random.Range(0, defender.parts_list.Length - 1); //this array stores def compoents health
                                        switch (deflist[spotd, number])
                                        {
                                        case 1:
                                            deflist[spotd, number] = 0;   //Component has been destroyed
                                            print(deflist[spotd, number] + "Component has been destroyed");
                                            break;

                                        default:
                                            deflist[spotd, number] -= 1;    //Ship takes a hull hit
                                            print(deflist[spotd, number] + "Ship took a hull hit");
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                print("Damage was done");
                                if (numofarmor != 0)  //armor has to be DESTROYED
                                {
                                    print("armor is under attack");
                                    Findarmor(defender.parts_list);
                                    deflist[spotd, loc]--;    //minus 1 health to armor
                                    if (deflist[spotd, loc] == 0)
                                    {
                                        numofarmor--;
                                    }
                                }
                                else
                                {
                                    print("Compoents under attack");
                                    number = Random.Range(0, defender.parts_list.Length - 1);    //this array stores def compoents health
                                    switch (deflist[spotd, number])
                                    {
                                    case 1:
                                        deflist[spotd, number] = 0;       //Component has been destroyed
                                        print(deflist[spotd, number] + "Component has been destroyed");
                                        break;

                                    default:
                                        deflist[spotd, number] -= 1;        //Ship takes a hull hit
                                        print(deflist[spotd, number] + "Ship took a hull hit");
                                        break;
                                    }
                                }
                            }
                        }
                        else//this is acutally unneeded but is good for debugging
                        {
                            print("Attack missed");
                        }
                    }
                    else if (numofmissle != 0)//Missile Attacks
                    {
                        numofmissle--;
                        if (Random.Range(0, 100) >= 50)         //50% of hitting with a hitting
                        {
                            if (numofantimissle != 0)           //do they have an anti missile
                            {
                                if (Random.Range(0, 100) <= 50) //50% of blocking
                                {
                                    print("Iron Dome activated");
                                }
                                else
                                {
                                    print("Damage was done");
                                    if (numofarmor != 0)
                                    {
                                        print("armor is under attack");
                                        Findarmor(defender.parts_list);
                                        deflist[spotd, loc]--; //minus 1 health to armor
                                        if (deflist[spotd, loc] == 0)
                                        {
                                            numofarmor--;
                                        }
                                    }
                                    else
                                    {
                                        print("Compoents under attack");
                                        number = Random.Range(0, defender.parts_list.Length - 1); //this array stores def compoents health
                                        switch (deflist[spotd, number])
                                        {
                                        case 1:
                                            deflist[spotd, number] = 0;   //Component has been destroyed
                                            print(deflist[spotd, number] + "Component has been destroyed");
                                            break;

                                        default:
                                            deflist[spotd, number] -= 1;    //Ship takes a hull hit
                                            print(deflist[spotd, number] + "Ship took a hull hit");
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                print("Damage was done");
                                if (numofarmor != 0)//armor has to be DESTROYED
                                {
                                    print("armor is under attack");
                                    Findarmor(defender.parts_list);
                                    deflist[spotd, loc]--; //minus 1 health to armor
                                    if (deflist[spotd, loc] == 0)
                                    {
                                        numofarmor--;
                                    }
                                }
                                else
                                {
                                    print("Compoents under attack");
                                    number = Random.Range(0, defender.parts_list.Length - 1); //this array stores def compoents health
                                    switch (deflist[spotd, number])
                                    {
                                    case 1:
                                        deflist[spotd, number] = 0;       //Component has been destroyed
                                        print(deflist[spotd, number] + "Component has been destroyed");
                                        break;

                                    default:
                                        deflist[spotd, number] -= 1;        //Ship takes a hull hit
                                        print(deflist[spotd, number] + "Ship took a hull hit");
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            print("Your missiles were a dud");
                        }
                    }
                }//end for loop
                attacker.hasAttacked = true;
                attacker             = null;
                defender             = null;
                resetweaps();
            }//End Attacker attacks Defender
            int value = 0;
            foreach (Ship_Class i in good)
            {
                if (i.hasAttacked == true && i != null)
                {
                    value++;
                }
                if (value == good.Length)
                {
                    Switchsides = true;
                    enableEndCombat();
                    Combattext.text = bad[0].faction + " is on the <color=red>attack</color>";
                    //Combattext.text = players.
                }
            }
            //print(Switchsides);
            if (attacker != null && defender != null && Switchsides == true)//Defender attacks Attacker
            {
                enableattackerbuttons();
                enabledefenderbuttons();
                print("defender turn");
                FindWeapons(defender.parts_list);
                FindDefense(attacker.parts_list);
                print(numofbeam + "  " + numofmissle + "  " + numofsheild + "   " + numofantimissle);
                if (numofbeam == 0 && numofmissle == 0)
                {
                    allzeros2 = true;
                }
                int weaps = numofbeam + numofmissle;
                for (int i = 0; i < weaps; i++)
                {
                    if (numofbeam != 0)
                    {
                        numofbeam--;
                        if (Random.Range(0, 100) <= 50)
                        {
                            if (numofsheild != 0)
                            {
                                numofsheild--;
                                if (Random.Range(0, 100) >= 50)//50% of blocking, if its more then 50 then block
                                {
                                    print("Damage was blocked");
                                }
                                else
                                {
                                    print("Damage was done");
                                    if (numofarmor != 0)//armor has to be DESTROYED
                                    {
                                        print("armor is under attack");
                                        Findarmor(attacker.parts_list);
                                        attlist[spota, loc]--; //minus 1 health to armor
                                        if (attlist[spota, loc] == 0)
                                        {
                                            numofarmor--;
                                        }
                                    }
                                    else//after armor is destroyed
                                    {
                                        print("Compoents under attack");
                                        number = Random.Range(0, attacker.parts_list.Length - 1); //this array stores def compoents health
                                        switch (attlist[spota, number])
                                        {
                                        case 1:
                                            attlist[spota, number] = 0;   //Component has been destroyed
                                            print(attlist[spotd, number] + "Component has been destroyed");
                                            break;

                                        default:
                                            attlist[spota, number] -= 1;   //Ship takes a hull hit
                                            print(attlist[spota, number] + "Ship took a hull hit");
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                print("Damage was done");
                                if (numofarmor != 0)  //armor has to be DESTROYED
                                {
                                    print("armor is under attack");
                                    Findarmor(attacker.parts_list);
                                    attlist[spota, loc]--;    //minus 1 health to armor
                                    if (attlist[spota, loc] == 0)
                                    {
                                        numofarmor--;
                                    }
                                }
                                else
                                {
                                    print("Compoents under attack");
                                    int number = Random.Range(0, attacker.parts_list.Length - 1);   //this array stores def compoents health
                                    switch (attlist[spota, number])
                                    {
                                    case 1:
                                        attlist[spota, number] = 0;       //Component has been destroyed
                                        print(attlist[spotd, number] + "Component has been destroyed");
                                        break;

                                    default:
                                        attlist[spota, number] -= 1;       //Ship takes a hull hit
                                        print(attlist[spota, number] + "Ship took a hull hit");
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            print("Defender Attack missed");
                        }
                    }
                    else if (numofmissle != 0)
                    {
                        numofmissle--;
                        if (Random.Range(0, 100) >= 50)         //50% of hitting with a hitting
                        {
                            if (numofantimissle != 0)           //do they have an anti missile
                            {
                                if (Random.Range(0, 100) <= 50) //50% of blocking
                                {
                                    print("Iron Dome activated");
                                }
                                else
                                {
                                    print("Damage was done");
                                    if (numofarmor != 0)
                                    {
                                        print("armor is under attack");
                                        Findarmor(attacker.parts_list);
                                        attlist[spota, loc]--; //minus 1 health to armor
                                        if (attlist[spota, loc] == 0)
                                        {
                                            numofarmor--;
                                        }
                                    }
                                    else
                                    {
                                        print("Compoents under attack");
                                        number = Random.Range(0, attacker.parts_list.Length - 1); //this array stores def compoents health
                                        switch (attlist[spota, number])
                                        {
                                        case 1:
                                            attlist[spota, number] = 0;   //Component has been destroyed
                                            print(attlist[spotd, number] + "Component has been destroyed");
                                            break;

                                        default:
                                            attlist[spota, number] -= 1;   //Ship takes a hull hit
                                            print(attlist[spota, number] + "Ship took a hull hit");
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                print("Damage was done");
                                if (numofarmor != 0)
                                {
                                    print("armor is under attack");
                                    Findarmor(attacker.parts_list);
                                    attlist[spota, loc]--;     //minus 1 health to armor
                                    if (attlist[spota, loc] == 0)
                                    {
                                        numofarmor--;
                                    }
                                }
                                else
                                {
                                    print("Compoents under attack");
                                    number = Random.Range(0, attacker.parts_list.Length - 1);   //this array stores def compoents health
                                    switch (attlist[spota, number])
                                    {
                                    case 1:
                                        attlist[spota, number] = 0;       //Component has been destroyed
                                        print(attlist[spotd, number] + "Component has been destroyed");
                                        break;

                                    default:
                                        attlist[spota, number] -= 1;       //Ship takes a hull hit
                                        print(attlist[spota, number] + " Ship took a hull hit");
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            print("Your missiles were a dud");
                        }
                    }
                }//endforloop
                defender.hasAttacked = true;
                attacker             = null;
                defender             = null;
                resetweaps();
                //good.Clear(good,0,goods);
                //bad.Clear(bad,0,bads);
                endofround = true;
            }

            value = 0;
            foreach (Ship_Class i in bad)
            {
                if (i.hasAttacked == true && i != null)
                {
                    value++;
                }
                if (value == bad.Length)
                {
                    Switchsides     = false;
                    Combattext.text = good[0].faction + " is on the <color=red>attack</color>";
                    enableEndCombat();
                }
            }
            resetattackbools();

            if (endofround)
            {
                calcdamges(); //good spot
            }
            if (!combat)      // this acutally  can't happen due to clac damages not fully impletented
            {
                good = null;
                bad  = null;
                //endofround = false;
            }
        }
    }
Example #10
0
 void Awake()
 {
     this.ship = null;
 }
Example #11
0
    // Update is called once per frame
    void Update()
    {
        //print("HEY");
        if (ships.Length == 0)                                                                      //Set array length, after ships are initialized in Start
        {
            //print("Hey " + GameObject.FindObjectsOfType<Ship_Class>().Length);
            ships = new Ship_Class[GameObject.FindObjectsOfType <Ship_Class>().Length];
        }

        if (true)                                                                                   //Find selected ships to populate ships[]
        {
            int          j     = 0;
            Ship_Class[] temp2 = GameObject.FindObjectsOfType <Ship_Class>();
            foreach (Ship_Class i in temp2)
            {
                if (i != null && i.selected == true)
                {
                    ships[j] = i;
                    j++;
                }
                else
                {
                    ships[j] = null;
                }
            }
        }
        //print(selector+" "+ships[selector]);
        if (ships[selector] != null)                                                                 //If button has ship associated with it, select it
        {
            selected_ship = ships[selector];
        }
        if (selected_ship != null)
        {
            //if(part2 != null)
            //print(part2.name + " " + (selected_ship.getShipType() + "(Clone)"));
            if (part2 == null || part2.name != (selected_ship.getShipType() + "(Clone)"))
            {
                part2 = Instantiate((GameObject)Resources.Load(selected_ship.getShipType()), this.transform);
                int h = 0;
                foreach (Button i in part2.GetComponentsInChildren <Button>())
                {
                    //print("Button " + i.name + " " + h);
                    i.onClick.AddListener(() => install(int.Parse(i.name)));
                    part_view[h] = i.GetComponent <Image>();
                    h++;
                }
            }

            int u = 0;
            //part_view = new Image[selected_ship.parts_list.Length];
            foreach (Component_Class i in selected_ship.parts_list)
            {
                if (i != null)
                {
                    part_view[u].sprite = i.getSprite();
                }
                u++;
            }
        }
        //print("What up?");
        if (Ship_list[0].GetComponentInParent <Canvas>().enabled == true)                            //If Canvas enabled, update UI
        {
            if (selected_ship != null)
            {
                Ship_list[0].text = selected_ship.name;
            }
            int k = 0;
            //print("YO " + ships[0]);
            foreach (Ship_Class i in ships)                                                         //Populate text for ships list
            {
                //print("YOU " + i.name);
                if (Ship_list[k + 1] != null)
                {
                    //print("In if "+ships[k].name);
                    if (ships[k] != null)
                    {
                        //print("Fill text box "+Ship_list[k+1].name+ " with "+i.name);
                        Ship_list[k + 1].text = i.name;
                        k++;
                    }
                    else
                    {
                        Ship_list[k + 1].text = "";
                    }
                }
            }

            //print(selected_ship);
            if (selected_ship != null)                                                             //If Canvas enabled and ship is selected,
            {                                                                                      //Find faction Shipyard and available components
                bool             temp3 = true;
                Shipyard_Class[] temp;
                temp = GameObject.FindObjectsOfType <Shipyard_Class>();
                foreach (Shipyard_Class i in temp)
                {
                    if (selected_ship.pos == i.GetComponent <Transform>().position&& i.faction == selected_ship.faction)
                    {
                        print("truw");
                        inRange = i.component_storage;
                        current = i;
                        temp3   = false;
                    }
                }
                if (temp3 == true)                                                                       //If no shipyard found, set to -1
                {
                    inRange = new int[] { -1, -1, -1, -1, -1, -1, -1, -1 };
                    current = null;
                }
            }
            int p = 0;
            foreach (int i in inRange)
            {
                parts_avail[p].text = "" + i;
                p++;
            }
        }
    }