Exemple #1
0
        public void SetUserCube(Vector3 pos)
        {
            _cubeParent.transform.position = pos;
            Timer = 0f;

            //Begin type placement process
            var typeMap             = new ZCubeType[_amountOfCubesWithinRange];
            var transmissiveTypeAmt = (ZCubeType.Transmissive3 - ZCubeType.Transmissive1) + 1;

            for (var i = 0; i < transmissiveTypeAmt; i++)
            {
                var amt = Random.Range(1, Mathf.Max(1, Mathf.RoundToInt(
                                                        ((float)_amountOfCubesWithinRange / transmissiveTypeAmt) * 0.04f)));
                for (var j = 0; j < amt; j++)
                {
                    int rand;
                    do
                    {
                        rand = Random.Range(0, _amountOfCubesWithinRange);
                    } while (typeMap[rand] != ZCubeType.Basic);
                    typeMap[rand] = ZCubeType.Transmissive1 + i;
                }
            }

            //Set the types
            var         inRangeIndex = 0;
            const float maxRangeSq   = MaxRange * MaxRange;
            const float minRangeSq   = MinRange * MinRange;

            foreach (var zCube in Cubes) //set other cubes
            {
                if (zCube.Type == ZCubeType.Player)
                {
                    continue;
                }
                if ((GameCore.Instance.Player.GoalPosition - zCube.transform.position).magnitude < 0.5f)
                {
                    zCube.Type = ZCubeType.Goal;
                    continue;
                }

                var distSq = zCube.transform.localPosition.sqrMagnitude;
                if (distSq > minRangeSq && distSq < maxRangeSq)
                {
                    zCube.Type = typeMap[inRangeIndex];
                    inRangeIndex++;
                }
                else
                {
                    zCube.Type = ZCubeType.Basic;
                }
            }
        }
Exemple #2
0
        private void Start()
        {
            DOTween.Init();
            CamOffset = Camera.main.transform.position;
            GameCore.Instance.Player = this;
            CalculateGoalPosition();
            Boosts = new List <int>();

            MessageBroker.Default.Receive <GameStateChangeEvent>().Subscribe(ev =>
            {
                if (ev.State == GameState.AwaitingTransmission)
                {
                    CurrentCubeType = NextCubeType;
                    if (CurrentCubeType == ZCubeType.Goal)
                    {
                        GameCore.Instance.State = GameState.LevelCompleted;
                    }
                }
            });
        }
Exemple #3
0
        private void NormalMove(ZCube cube)
        {
            if (IsBoostActive || (((cube.Type >= ZCubeType.Transmissive1 && cube.Type <= ZCubeType.Transmissive3) || cube.Type == ZCubeType.Goal) && (cube.transform.localScale.y > 8f || IsBoostActive)))//NodeSelect Logic here
            {
                if (IsBoostActive)
                {
                    GameCore.TransmissionDuration = GameCore.GetBoostSpeed() * (transform.position - cube.transform.position).magnitude;
                }
                else
                {
                    GameCore.TransmissionDuration = GameCore.GetNormalSpeed() * (transform.position - cube.transform.position).magnitude;
                }

                Score += Mathf.CeilToInt((transform.position - cube.transform.position).magnitude * Level);
                transform.position = cube.transform.position;//Move player
                Camera.main.transform.DOMove(transform.position + CamOffset, GameCore.TransmissionDuration);
                GameCore.Instance.State = GameState.Transmitting;
                NextCubeType            = cube.Type;
            }
        }
Exemple #4
0
        public static Color GetCubeColor(ZCubeType type)
        {
            if (type == ZCubeType.Player) //bad practice
            {
                type = GameCore.Instance.Player.CurrentCubeType;
            }
            switch (type)
            {
            case ZCubeType.Goal:
                return(Color.green);

            case ZCubeType.Transmissive1:
                return(new Color(1f, 0.34f, 1f));

            case ZCubeType.Transmissive2:
                return(new Color(1f, 0.71f, 0f));

            case ZCubeType.Transmissive3:
                return(new Color(0f, 1f, 0.82f));

            default:
                return(Color.clear);
            }
        }