Exemplo n.º 1
0
    private void InitGrid()
    {
        ShipProperties shipProperties = gameData.ShipTypesDictionary[this.shipController.ShipType];

        this.gridLayoutGroup = this.panel.GetComponent <GridLayoutGroup>();

        panelTransform.sizeDelta = new Vector2(
            (gridLayoutGroup.cellSize.x + gridLayoutGroup.spacing.x) * shipProperties.columns,
            (gridLayoutGroup.cellSize.y + gridLayoutGroup.spacing.y) * shipProperties.rows
            );

        this.shipGrid = new SlotController[shipProperties.rows, shipProperties.columns];
        for (int i = 0; i < shipProperties.rows; i++)
        {
            for (int j = 0; j < shipProperties.columns; j++)
            {
                GameObject newSlot = Instantiate(ButtonPrefab, new Vector3(0, 0, 0), Quaternion.identity);
                newSlot.transform.SetParent(this.panel.transform);
                newSlot.name = "Slot_" + (i * shipProperties.columns + j);
                // newButton.name = i + " " + j;
                newSlot.GetComponent <SlotController>().Init(j, i);
                // newButton.GetComponent<Button>().onClick.AddListener(newButton.GetComponent<SlotController>().OnClick);

                this.slots.Add(newSlot);
                this.shipGrid[i, j] = newSlot.GetComponent <SlotController>();
            }
        }
    }
Exemplo n.º 2
0
 void Start()
 {
     ship = ShipProperties.Instantiate(ship);
     if (damage)
     {
         ship.Hull.Value -= 1;
     }
     Debug.Log(ship.Hull.Value);
 }
Exemplo n.º 3
0
        public virtual void Trigger(WeaponModifiers weaponModifiers, ShipProperties shipProperties)
        {
            if (!(this.timeUntilTrigger <= 0))
            {
                return;
            }

            this.timeUntilTrigger = 0;
            TriggerEffect(weaponModifiers, shipProperties);
            this.timeUntilTrigger += this.TriggerRate * weaponModifiers.Speed;
        }
Exemplo n.º 4
0
    protected virtual void Start()
    {
        properties = ShipProperties.Instantiate(properties);
        zone       = GetComponent <FiringZone>();
        TurnOrder.Instance.Subscribe(this);

        actions = new ActionProperties[weapons.Length];
        for (int i = 0; i < weapons.Length; i++)
        {
            weapons[i] = WeaponProperties.Instantiate(weapons[i]);
            actions[i] = weapons[i];
        }
    }
Exemplo n.º 5
0
 void OnEnable()
 {
     ship = target as ShipProperties;
 }
Exemplo n.º 6
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hitInfo;
            target = ReturnClickedObject(out hitInfo);

            if (target != null)
            {
                if (!grabbed)
                {
                    if ((MatchDatas.getActiveShip() == null || MatchDatas.getActiveShip() != target) && target.GetComponent <ShipProperties>() != null)
                    {
                        MatchHandlerUtil.hideActiveShipHighlighters();
                        MatchHandlerUtil.hideFiringArcs();

                        LoadedShip     activeShip = new LoadedShip();
                        ShipProperties sp         = target.GetComponent <ShipProperties>();

                        activeShip = sp.getLoadedShip();

                        MatchDatas.getPlayers()[MatchDatas.getActivePlayerIndex()].setActiveShip(activeShip);
                        MatchDatas.getPlayers()[MatchDatas.getActivePlayerIndex()].setSelectedShip(activeShip);

                        MatchHandlerUtil.setShipHighlighters(target, true);
                        MatchDatas.setActiveShip(target);
                    }
                }

                if (MatchDatas.getCurrentPhase() == MatchDatas.phases.SQUADRON_PLACEMENT || MatchDatas.getCurrentPhase() == MatchDatas.phases.ASTEROIDS_PLACEMENT)
                {
                    Cursor.visible = false;
                    grabbed        = true;
                    prevPos        = target.transform.position;
                }
                else if (MatchDatas.getCurrentPhase() == MatchDatas.phases.ACTIVATION && target.GetComponent <ShipProperties>() != null)
                {
                    foreach (LoadedShip ship in MatchHandler.getAvailableShips())
                    {
                        if (
                            target.transform.GetComponent <ShipProperties>().getLoadedShip().getShip().ShipId.Equals(ship.getShip().ShipId) &&
                            target.transform.GetComponent <ShipProperties>().getLoadedShip().getPilotId() == ship.getPilotId() &&
                            !target.transform.GetComponent <ShipProperties>().getLoadedShip().isHasBeenActivatedThisRound()
                            )
                        {
                            target.transform.GetComponent <ShipProperties>().getLoadedShip().setHasBeenActivatedThisRound(true);
                            StartCoroutine(GameObject.Find("ScriptHolder").GetComponent <CoroutineHandler>().MoveShipOverTime(target, target.transform.GetComponent <ShipProperties>().getLoadedShip().getPlannedManeuver()));
                        }
                    }
                }
            }
        }

        if (Input.GetMouseButtonUp(0) && grabbed)
        {
            Cursor.visible = true;
            grabbed        = false;

            if (target.GetComponent <ShipProperties>() != null)
            {
                GameObject shipCollection = GameObject.Find("ShipCollection1");
                GameObject setupField     = GameObject.Find("Player1SetupField");

                // TODO check if this part can be simplyfied....
                if (!shipCollection.GetComponent <Collider>().bounds.Contains(target.transform.position) && !setupField.GetComponent <Collider>().bounds.Contains(target.transform.position))
                {
                    target.transform.position = prevPos;
                }
                else
                {
                    if (setupField.GetComponent <Collider>().bounds.Contains(target.transform.position) && shipCanBeMoved())
                    {
                        togglePositionConfirmButton(true);
                    }
                }

                if (!setupField.GetComponent <Collider>().bounds.Contains(target.transform.position))
                {
                    togglePositionConfirmButton(false);
                }
                // TODO check if this part can be simplyfied....
            }

            if (target.GetComponent <AsteroidProperties>() != null)
            {
                GameObject playField = GameObject.Find("Playfield");

                // TODO Check distance from playfield borders and other asteroids!!
                if (!playField.GetComponent <Collider>().bounds.Contains(target.transform.position) || isAsteroidTooClose())
                {
                    target.transform.position = prevPos;
                }
                else
                {
                    if (allAsteroidsAreInsidePlayfield())
                    {
                        togglePositionConfirmButton(true);
                    }
                }
            }
        }

        if (grabbed && MatchDatas.getCurrentPhase() == MatchDatas.phases.SQUADRON_PLACEMENT && shipCanBeMoved())
        {
            if (Input.GetAxis("Mouse ScrollWheel") > 0f) // forward
            {
                target.transform.RotateAround(target.transform.position, target.transform.TransformDirection(Vector3.up), 2.5f);
            }
            else if (Input.GetAxis("Mouse ScrollWheel") < 0f) // backwards
            {
                target.transform.RotateAround(target.transform.position, target.transform.TransformDirection(Vector3.up), -2.5f);
            }
        }
    }
Exemplo n.º 7
0
 public override void ActivateEffect(WeaponModifiers weaponModifiers, ShipProperties shipProperties)
 {
     weaponModifiers.Multiplier += 1;
 }
Exemplo n.º 8
0
 public virtual void TriggerEffect(WeaponModifiers weaponModifiers, ShipProperties shipProperties)
 {
 }
Exemplo n.º 9
0
 public virtual void ActivateEffect(WeaponModifiers weaponModifiers, ShipProperties shipProperties)
 {
 }
Exemplo n.º 10
0
 protected void GetShipData()
 {
     shipProperties = new ShipProperties(DataManager.Instance.currentShipData.health, DataManager.Instance.currentShipData.damage, DataManager.Instance.currentShipData.defense, DataManager.Instance.currentShipData.fireRate);
 }
Exemplo n.º 11
0
 public override void ActivateEffect(WeaponModifiers weaponModifiers, ShipProperties shipProperties)
 {
     weaponModifiers.Speed -= 0.1f;
 }