public override void Construct(BattleManager battleManager, Map map, BattleController currentBattleController)
        {
            this.battleManager           = battleManager;
            this.map                     = map;
            this.currentBattleController = currentBattleController;
            mainUI = battleManager.mainUI;

            currentCharControl             = (CharacterBattleController)currentBattleController;
            _currentCharacterDataComponent = currentCharControl.characterDataComponent;

            Tile curTile = _currentCharacterDataComponent.position;

            Vector3 curTilePoint =
                map.GetCoordByTileIndexes(curTile.x, curTile.z, curTile.y);
            Vector3 vect  = curTilePoint + new Vector3(0, 0.7f, 0);
            Vector2 vect2 = Camera.main.WorldToScreenPoint(vect);

            confirmButtonGameObject =
                Instantiate(Resources.Load("UIElements/ConfirmBtn")) as GameObject;
            confirmButtonGameObject.transform.SetParent(mainUI.transform, false);
            confirmButton = confirmButtonGameObject.GetComponent <Button>();
            confirmButton.onClick.AddListener(ConfirmTarget);
            confirmButtonGameObject.GetComponent <UIinSpace>()
            .Initiate(vect, new Vector2(20, 45));
        }
Beispiel #2
0
        public FrozenEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name            = "Frozen";
            this.description     = "Skips turn";
            this.baseDuration    = 1;
            this.duration        = 1;
            this.iconResourceURL = "AbilityIcons/CryoblastAbIcon";

            this.despelable = true;
            this.positive   = false;
        }
Beispiel #3
0
        public StimulatorEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name            = "Stimulator";
            this.description     = "Replenish 7 HP per turn. Increases speed by 1. Increases AP recovery per tern by 1";
            this.baseDuration    = 2;
            this.duration        = 2;
            this.iconResourceURL = "AbilityIcons/StimulatorAbIcon";

            this.despelable = false;
            this.positive   = true;
        }
Beispiel #4
0
        public BurnEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name            = "Burn";
            this.description     = "-10 HP every turn";
            this.baseDuration    = 3;
            this.duration        = 3;
            this.iconResourceURL = "AbilityIcons/FlareAbIcon";

            this.despelable = true;
            this.positive   = false;
        }
Beispiel #5
0
        public ScannedEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name            = "Scanned";
            this.description     = "Takes 50% more damage";
            this.baseDuration    = 2;
            this.duration        = 2;
            this.iconResourceURL = "AbilityIcons/VulnerabilityScanAbIcon";

            this.despelable = true;
            this.positive   = false;
        }
Beispiel #6
0
        public StunnedEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name            = "Stunned";
            this.description     = "Skips turn";
            this.baseDuration    = 1;
            this.duration        = 1;
            this.iconResourceURL = "AbilityIcons/OverloadAbIcon";

            this.despelable = true;
            this.positive   = false;
        }
Beispiel #7
0
        public AdrenalineEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name            = "Adrenaline";
            this.description     = "-2 EP recovery per turn";
            this.baseDuration    = 1;
            this.duration        = 1;
            this.iconResourceURL = "AbilityIcons/AdrenalineAbIcon";

            this.despelable = false;
            this.positive   = false;
        }
Beispiel #8
0
        public ShockEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name            = "Shocked";
            this.description     = "-1 EP recovery per turn";
            this.baseDuration    = 2;
            this.duration        = 2;
            this.iconResourceURL = "AbilityIcons/OverloadAbIcon";

            this.despelable = true;
            this.positive   = false;
        }
        public override void Construct(BattleManager battleManager, Map map, BattleController currentBattleController)
        {
            this.battleManager           = battleManager;
            this.map                     = map;
            this.currentBattleController = currentBattleController;
            mainUI = battleManager.mainUI;

            currentCharControl             = (CharacterBattleController)currentBattleController;
            _currentCharacterDataComponent = currentCharControl.characterDataComponent;

            currentCharControl.DeltaAPRed(2);

            initiated = true;
        }
Beispiel #10
0
        public WetEffect(CharacterBattleController characterBattleController)
        {
            this.characterBattleController = characterBattleController;
            this.name         = "Wet";
            this.description  = "Just wet, beware of electricity!";
            this.baseDuration = 1;
            this.duration     = 1;

            // TODO: need to change icon!
            this.iconResourceURL = "AbilityIcons/ConfirmIcon";

            this.despelable = true;
            this.positive   = false;
        }
Beispiel #11
0
        public override void Construct(BattleManager battleManager, Map map, BattleController currentBattleController)
        {
            this.battleManager           = battleManager;
            this.map                     = map;
            this.currentBattleController = currentBattleController;
            mainUI = battleManager.mainUI;

            currentCharControl             = (CharacterBattleController)currentBattleController;
            _currentCharacterDataComponent = currentCharControl.characterDataComponent;

            maxPathLength = _currentCharacterDataComponent.ap *
                            (_currentCharacterDataComponent.speed + _currentCharacterDataComponent.speedModifier);

            initiated = true;
        }
        private void Update()
        {
            if (initiated)
            {
                int mask = (1 << 9) | (1 << 13);
                //mask = ~mask;

                RaycastHit hitInfo = new RaycastHit();
                bool       hit     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo,
                                                     Single.PositiveInfinity, mask);
                if (hit)
                {
                    //check on traversability
                    courser.transform.position = map.GetCourserPosition(hitInfo.point);
                }

                if (targetSelected)
                {
                    if (Input.GetMouseButton(1))
                    {
                        timeHoldingBtn += Time.deltaTime;
                    }

                    if (Input.GetMouseButtonUp(1))
                    {
                        if (timeHoldingBtn <= 0.3f)
                        {
                            Deselect();
                        }

                        timeHoldingBtn = 0;
                    }
                }
                else
                {
                    if (Input.GetMouseButtonUp(0))
                    {
                        if (EventSystem.current.IsPointerOverGameObject())
                        {
                            return;
                        }

                        RaycastHit hitLMBInfo = new RaycastHit();
                        bool       hitLMB     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),
                                                                out hitLMBInfo,
                                                                Single.PositiveInfinity, mask);
                        if (hitLMB)
                        {
                            Component bc;
                            if (hitLMBInfo.collider.TryGetComponent(typeof(BattleController), out bc))
                            {
                                targetForAttack =
                                    hitLMBInfo.collider.gameObject.GetComponent <CharacterBattleController>();
                                if (currentCharControl.characterDataComponent.ap > 1)
                                {
                                    Vector3 attackAlignment =
                                        hitLMBInfo.collider.gameObject.transform.position -
                                        gameObject.transform.position;

                                    float angle = Vector3.SignedAngle(attackAlignment, Vector3.forward, Vector3.up);

                                    int adjIndex         = TargetingUtils.GetAdjIndexByAngle(angle);
                                    int opponentAdjIndex = (adjIndex + 2) % 4;

                                    List <Vector3> attackOrigin =
                                        TargetingUtils.GetPointsOrigin(map, _currentCharacterDataComponent.position,
                                                                       adjIndex);
                                    List <Vector3> attackDestination =
                                        TargetingUtils.GetPointsOrigin(map,
                                                                       targetForAttack.characterDataComponent.position,
                                                                       opponentAdjIndex);

                                    foreach (Vector3 origin in attackOrigin)
                                    {
                                        foreach (Vector3 destination in attackDestination)
                                        {
                                            // int maskForAttack = ~(1 << 9);
                                            RaycastHit hitAtckInfo = new RaycastHit();
                                            bool       hitAtck     = Physics.Raycast(origin, destination - origin,
                                                                                     out hitAtckInfo,
                                                                                     (destination - origin).magnitude);

                                            Debug.DrawLine(origin, destination, Color.white, 5);

                                            if (!hitAtck || hitAtckInfo.collider.gameObject
                                                .GetComponent <CharacterBattleController>() == targetForAttack)
                                            {
                                                originForAttack      = origin;
                                                destinationForAttcak = destination;

                                                Tile curTile = targetForAttack.characterDataComponent.position;

                                                Vector3 curTilePoint =
                                                    map.GetCoordByTileIndexes(curTile.x, curTile.z, curTile.y);
                                                Vector3 vect  = curTilePoint + new Vector3(0, 0.7f, 0);
                                                Vector2 vect2 = Camera.main.WorldToScreenPoint(vect);

                                                confirmButtonGameObject =
                                                    Instantiate(Resources.Load("UIElements/ConfirmBtn")) as GameObject;
                                                confirmButtonGameObject.transform.SetParent(mainUI.transform, false);
                                                confirmButton = confirmButtonGameObject.GetComponent <Button>();
                                                confirmButton.onClick.AddListener(ConfirmTarget);
                                                confirmButtonGameObject.GetComponent <UIinSpace>()
                                                .Initiate(vect, new Vector2(20, 45));

                                                targetSelected = true;
                                                return;
                                            }
                                            else
                                            {
                                                //Debug.Log("Attack is unavailable!");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (Input.GetMouseButton(1))
                    {
                        timeHoldingBtn += Time.deltaTime;
                    }

                    if (Input.GetMouseButtonUp(1))
                    {
                        if (timeHoldingBtn <= 0.3f)
                        {
                            // SwapTargetingController
                            // EndTargeting();
                            currentCharControl.SwapTargeting(0);
                        }

                        timeHoldingBtn = 0;
                    }
                }
            }
        }
Beispiel #13
0
        private void Update()
        {
            if (initiated)
            {
                // TODO: Correct mask!
                int mask = (1 << 9) | (1 << 13);
                //mask = ~mask;

                RaycastHit hitInfo = new RaycastHit();
                bool       hit     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo,
                                                     Single.PositiveInfinity, mask);
                if (hit)
                {
                    //check on traversability
                    if (map.GetTileByVectorPoint(hitInfo.point) != null &&
                        map.GetTileByVectorPoint(hitInfo.point).traversable)
                    {
                        courser.transform.position = map.GetCourserPosition(hitInfo.point);
                    }
                }

                if (moveConfirm)
                {
                    if (Input.GetMouseButtonUp(0))
                    {
                        if (EventSystem.current.IsPointerOverGameObject())
                        {
                            return;
                        }

                        if (path.Count < maxPathLength)
                        {
                            RaycastHit hitLMBInfo = new RaycastHit();
                            bool       hitLMB     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),
                                                                    out hitLMBInfo,
                                                                    Single.PositiveInfinity, mask);
                            if (hitLMB)
                            {
                                if (hitLMBInfo.collider.gameObject.tag.Equals("Floor"))
                                {
                                    curPath = MapUtils.FindPath(map, path.Last(),
                                                                map.GetTileByVectorPoint(hitLMBInfo.point));
                                    if (curPath.Count + path.Count > maxPathLength)
                                    {
                                        curPath = curPath.GetRange(0, maxPathLength - path.Count);
                                    }

                                    curTile = curPath.Last();
                                    Vector3 pathPoint = map.GetCoordByTileIndexes(curTile.x, curTile.z, curTile.y);

                                    additionalRingCoursers.Add(Instantiate(middlePointMapCourserPrefab,
                                                                           pathPoint, Quaternion.identity));
                                    Vector3 vect  = pathPoint + new Vector3(0, 0.7f, 0);
                                    Vector2 vect2 = Camera.main.WorldToScreenPoint(vect);

                                    GameObject text = Instantiate(Resources.Load("UIElements/MoveStep")) as GameObject;
                                    text.transform.SetParent(mainUI.transform, false);
                                    text.GetComponent <UIinSpace>().Initiate(vect);
                                    text.GetComponent <UIinSpace>().ChangeText(additionalRingCoursers.Count.ToString());
                                    additionalNumberCoursers.Add(text);

                                    confirmButtonGameObject.GetComponent <UIinSpace>()
                                    .Initiate(vect, new Vector2(20, 45));

                                    path.AddRange(curPath);

                                    APcostForMovement =
                                        (int)Math.Ceiling((double)path.Count /
                                                          (double)(_currentCharacterDataComponent.speed + _currentCharacterDataComponent.speedModifier));
                                    currentCharControl.DeltaAPRed(APcostForMovement);
                                }
                            }
                        }
                        else
                        {
                            // TODO: Make notification here!
                        }
                    }
                }
                else if (attackConfirm)
                {
                }
                else if (state)
                {
                    if (Input.GetMouseButtonUp(0))
                    {
                        //need this shit to prevent clicking Under UI
                        if (EventSystem.current.IsPointerOverGameObject())
                        {
                            return;
                        }

                        RaycastHit hitLMBInfo = new RaycastHit();
                        bool       hitLMB     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),
                                                                out hitLMBInfo,
                                                                Single.PositiveInfinity, mask);
                        if (hitLMB)
                        {
                            if (hitLMBInfo.collider.gameObject.tag.Equals("Floor"))
                            {
                                // !!!
                                // TODO: Check if tile can be found in Dictionary, otherwise there will be error here!
                                // !!!

                                curPath = MapUtils.FindPath(map, _currentCharacterDataComponent.position,
                                                            map.GetTileByVectorPoint(hitLMBInfo.point));
                                if (curPath.Count > maxPathLength)
                                {
                                    curPath = curPath.GetRange(0, maxPathLength);
                                }

                                curTile = curPath.Last();
                                Vector3 pathPoint = map.GetCoordByTileIndexes(curTile.x, curTile.z, curTile.y);

                                additionalRingCoursers.Add(Instantiate(middlePointMapCourserPrefab,
                                                                       pathPoint, Quaternion.identity));
                                Vector3 vect  = pathPoint + new Vector3(0, 0.7f, 0);
                                Vector2 vect2 = Camera.main.WorldToScreenPoint(vect);

                                GameObject text = Instantiate(Resources.Load("UIElements/MoveStep")) as GameObject;
                                text.transform.SetParent(mainUI.transform, false);
                                text.GetComponent <UIinSpace>().Initiate(vect);
                                text.GetComponent <UIinSpace>().ChangeText("1");
                                additionalNumberCoursers.Add(text);

                                confirmButtonGameObject =
                                    Instantiate(Resources.Load("UIElements/MoveBtn")) as GameObject;
                                confirmButtonGameObject.transform.SetParent(mainUI.transform, false);
                                confirmButton = confirmButtonGameObject.GetComponent <Button>();
                                confirmButton.onClick.AddListener(ConfirmTarget);
                                confirmButtonGameObject.GetComponent <UIinSpace>()
                                .Initiate(vect, new Vector2(20, 45));

                                path.AddRange(curPath);

                                APcostForMovement =
                                    (int)Math.Ceiling((double)path.Count /
                                                      (double)_currentCharacterDataComponent.speed);
                                currentCharControl.DeltaAPRed(APcostForMovement);

                                moveConfirm = true;

                                // Button button = Instantiate() as Button;
                                // button.onClick.AddListener(ConfirmTarget);
                            }

                            Component bc;

                            if (hitLMBInfo.collider.TryGetComponent(typeof(BattleController), out bc))
                            {
                                //Debug.Log("WOW! " + hitLMBInfo.collider.TryGetComponent(typeof(BattleController), out bc));


                                targetForAttack =
                                    hitLMBInfo.collider.gameObject.GetComponent <CharacterBattleController>();
                                if (currentCharControl.characterDataComponent.ap > 1)
                                {
                                    Vector3 attackAlignment =
                                        hitLMBInfo.collider.gameObject.transform.position -
                                        gameObject.transform.position;

                                    float angle = Vector3.SignedAngle(attackAlignment, Vector3.forward, Vector3.up);

                                    Debug.DrawLine(gameObject.transform.position,
                                                   gameObject.transform.position + attackAlignment, Color.red, 3.5f);
                                    Debug.DrawLine(targetForAttack.gameObject.transform.position,
                                                   targetForAttack.gameObject.transform.position + Vector3.forward, Color.blue,
                                                   3.5f);
                                    Debug.DrawLine(targetForAttack.gameObject.transform.position,
                                                   targetForAttack.gameObject.transform.position + Vector3.right, Color.yellow,
                                                   3.5f);
                                    Debug.DrawLine(targetForAttack.gameObject.transform.position,
                                                   targetForAttack.gameObject.transform.position + Vector3.back, Color.red, 3.5f);
                                    Debug.DrawLine(targetForAttack.gameObject.transform.position,
                                                   targetForAttack.gameObject.transform.position + Vector3.left, Color.black,
                                                   3.5f);

                                    int adjIndex         = TargetingUtils.GetAdjIndexByAngle(angle);
                                    int opponentAdjIndex = (adjIndex + 2) % 4;

                                    //Debug.Log("Angle = " + angle + " - " + adjIndex + ", " + opponentAdjIndex);

                                    List <Vector3> attackOrigin =
                                        TargetingUtils.GetPointsOrigin(map, _currentCharacterDataComponent.position,
                                                                       adjIndex);
                                    List <Vector3> attackDestination =
                                        TargetingUtils.GetPointsOrigin(map,
                                                                       targetForAttack.characterDataComponent.position,
                                                                       opponentAdjIndex);

                                    foreach (Vector3 origin in attackOrigin)
                                    {
                                        foreach (Vector3 destination in attackDestination)
                                        {
                                            // int maskForAttack = ~(1 << 9);
                                            RaycastHit hitAtckInfo = new RaycastHit();
                                            bool       hitAtck     = Physics.Raycast(origin, destination - origin,
                                                                                     out hitAtckInfo,
                                                                                     (destination - origin).magnitude);

                                            Debug.DrawLine(origin, destination, Color.white, 5);

                                            if (!hitAtck || hitAtckInfo.collider.gameObject
                                                .GetComponent <CharacterBattleController>() == targetForAttack)
                                            {
                                                originForAttack      = origin;
                                                destinationForAttcak = destination;

                                                curTile = targetForAttack.characterDataComponent.position;

                                                Vector3 pathPoint =
                                                    map.GetCoordByTileIndexes(curTile.x, curTile.z, curTile.y);
                                                Vector3 vect  = pathPoint + new Vector3(0, 0.7f, 0);
                                                Vector2 vect2 = Camera.main.WorldToScreenPoint(vect);

                                                confirmButtonGameObject =
                                                    Instantiate(Resources.Load("UIElements/AttackBtn")) as GameObject;
                                                confirmButtonGameObject.transform.SetParent(mainUI.transform, false);
                                                confirmButton = confirmButtonGameObject.GetComponent <Button>();
                                                confirmButton.onClick.AddListener(ConfirmTarget);
                                                confirmButtonGameObject.GetComponent <UIinSpace>()
                                                .Initiate(vect, new Vector2(20, 45));

                                                currentCharControl.DeltaAPRed(2);

                                                attackConfirm = true;

                                                return;
                                            }
                                            else
                                            {
                                                //Debug.Log("Attack is unavailable!");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (Input.GetMouseButton(1))
                {
                    timeHoldingBtn += Time.deltaTime;
                }

                if (Input.GetMouseButtonUp(1))
                {
                    if (timeHoldingBtn <= 0.3f)
                    {
                        Deselect();
                    }

                    timeHoldingBtn = 0;
                }
            }

            // throw new NotImplementedException();
        }