Esempio n. 1
0
 Enemy(Game game, GameColors gameColor)
     : base(game)
 {
     renderColor = GameColorsUtilities.GetSystemColor(gameColor);
     color = gameColor;
     IsAlive = true;
 }
Esempio n. 2
0
        private void SetColors(uint value)
        {
            var index = value == 0 ? 0 : (int)Math.Log(value, 2);

            BackgroundColor  = GameColors.GetTileBackgroundColor(index);
            _label.TextColor = GameColors.GetTileColor(index);
        }
Esempio n. 3
0
    public static GameColors[] getPrimaries(this GameColors color)
    {
        GameColors[] primaries;

        if (color == GameColors.Green)
        {
            primaries = new GameColors[2] {
                GameColors.Blue, GameColors.Yellow
            };
        }
        else if (color == GameColors.Purple)
        {
            primaries = new GameColors[2] {
                GameColors.Blue, GameColors.Red
            };
        }
        else if (color == GameColors.Orange)
        {
            primaries = new GameColors[2] {
                GameColors.Yellow, GameColors.Red
            };
        }
        else
        {
            primaries = new GameColors[1] {
                color
            };
        }

        return(primaries);
    }
 public static Projectile CreateProjectile(Game game, GameColors color)
 {
     released = false;
     if (unusedProjectiles[(int)color] == null)
     {
         unusedProjectiles[(int)color] = new Queue<Projectile>();
     }
     else if (unusedProjectilesToRelease[(int)color] != null)
     {
         foreach (var projectile in unusedProjectilesToRelease[(int)color])
         {
             if (projectile.ToRelease)
             {
                 unusedProjectiles[(int)color].Enqueue(projectile);
             }
             else
             {
                 projectile.ToRelease = true;
             }
         }
         unusedProjectilesToRelease[(int)color] = (from projectile in unusedProjectilesToRelease[(int)color]
                                                       where !projectile.ToRelease
                                                       select projectile).ToList();
     }
     if (unusedProjectiles[(int)color].Count > 0)
     {
         var projectile = unusedProjectiles[(int)color].Dequeue();
         return projectile;
     }
     var p = new Projectile(game, color);
     p.Initialize();
     return p;
 }
Esempio n. 5
0
//	private float time = 0;
    protected void Update()
    {
        if (iShoot)
        {
//			time += Time.deltaTime;
//			if (time > 1) {
//				time = 0;
//				CalculateSpitDirections ();
//				SpitShot (new Shot.ShotParams ());
//			}

            currentColor = GameColors.Purple;
            EatColor(new Shot.ShotParams(Shot.ShotTypes.ColorShot, GameColors.Yellow, 2));
            iShoot = false;
        }

        timeTillIdle += Time.deltaTime;
        if (timeTillIdle > nextIdleTime)
        {
            int trigger = Random.value > 0.5 ? IDLE_1_TRIGGER : IDLE_2_TRIGGER;
            animator.SetTrigger(trigger);
            nextIdleTime = Random.Range(idleMinTime, idleMaxTime);
            timeTillIdle = 0;
        }
    }
Esempio n. 6
0
        public MoveResult EvaluateCurrentMove(GameColors[] guessedColors)
        {
            CurrentMove.GuessedColors = guessedColors;
            MoveResult moveResult = CurrentMove.MoveResult;

            for (var i = 0; i < CurrentMove.GuessedColors.Count(); i++)
            {
                GameColors guessedColor = CurrentMove.GuessedColors[i];
                if (guessedColor == DecodingBoard[i])
                {
                    moveResult.EvaluatedResultColors[i] = ResultColors.Black;
                }
                else if (DecodingBoard.Contains(guessedColor))
                {
                    moveResult.EvaluatedResultColors[i] = ResultColors.White;
                }
                else
                {
                    moveResult.EvaluatedResultColors[i] = ResultColors.Undefined;
                }
            }

            moveResult.EvaluatedResultColors = moveResult.EvaluatedResultColors.OrderBy(e => (int)e).ToArray();
            return(moveResult);
        }
Esempio n. 7
0
    public static string GetHexColor(GameColors colors)
    {
        switch (colors)
        {
        case GameColors.None:
            return("#00000000");

        case GameColors.White:
            return("#FFFFFF");

        case GameColors.Blue:
            return("#0047ab");

        case GameColors.Black:
            return("#000000");

        case GameColors.White | GameColors.Blue:
            return("#80A3D5");

        case GameColors.Blue | GameColors.Black:
            return("#002456");

        case GameColors.White | GameColors.Black:
            return("#808080");

        case GameColors.White | GameColors.Blue | GameColors.Black:
            return("#556D8E");

        default:
            return("#00000000");
        }
    }
Esempio n. 8
0
    public void updateScore(GameColors prevColor, GameColors newColor)
    {
        if (prevColor == GameColors.Green)
        {
            numGreen--;
        }
        else if (prevColor == GameColors.Purple)
        {
            numPurple--;
        }
        else if (prevColor == GameColors.Orange)
        {
            numOrange--;
        }

        if (newColor == GameColors.Green)
        {
            numGreen++;
        }
        else if (newColor == GameColors.Purple)
        {
            numPurple++;
        }
        else if (newColor == GameColors.Orange)
        {
            numOrange++;
        }

        int numMixed = Mathf.Max(1, numGreen + numPurple + numOrange);

        greenScoreSlider.value  = (float)(numGreen) / numMixed;
        purpleScoreSlider.value = (float)(numPurple) / numMixed;
        orangeScoreSlider.value = (float)(numOrange) / numMixed;
    }
        public void GetsColorsMatchingTheStarClass(string starClass, int rgbColor)
        {
            var expectedColor = Color.FromRgb((uint)rgbColor);

            var color = GameColors.GetStarClassColor(starClass);

            Assert.Equal(expectedColor, color);
        }
 public void ColorChange(GameColors color, GameColors prev)
 {
     Debug.Log("color change" + color + prev);
     numColored[(int)color]++;
     numColored[(int)prev]--;
     if (numColored[(int)color] == numBlocks) {
         Win ();
     }
 }
Esempio n. 11
0
    public UserInfo(Dictionary <string, object> userJson)
    {
        cxId     = userJson["cxId"] as string;
        ID       = userJson["profileId"] as string;
        Username = userJson["name"] as string;
        Dictionary <string, object> extra = userJson["extra"] as Dictionary <string, object>;
        int colorIndex = (int)extra["colorIndex"];

        UserGameColor = (GameColors)colorIndex;
    }
Esempio n. 12
0
    public void NextColor()
    {
        GameColors nextColors = _currentColors;

        while (nextColors == _currentColors)
        {
            nextColors = (GameColors)Random.Range(1, 8);
        }
        setColor(nextColors);
    }
Esempio n. 13
0
    void setFlagColors()
    {
        GameColors myColor = this.targetColors[this.playerId];

        this.myFlag[0].color = myColor.GetColor();
        this.myFlag[1].color = myColor.getPrimaries()[0].GetColor();
        this.myFlag[2].color = myColor.getPrimaries()[1].GetColor();

        this.opponentFlags[1].color = this.targetColors[(this.playerId + 1) % this.targetColors.Length].GetColor();
        this.opponentFlags[0].color = this.targetColors[(this.playerId + 2) % this.targetColors.Length].GetColor();
    }
Esempio n. 14
0
    void NewPotion(Vector3 pos, GameColors color)
    {
        GameObject newPotion = (GameObject)GameObject.Instantiate(PotionPrefab);

        newPotion.transform.parent = this.transform;
        pos.y = newPotion.transform.position.y;
        newPotion.transform.position = pos;
        Potion potion = (Potion)newPotion.GetComponent(typeof(Potion));

        potion.color = color;
        potion.FillColor(color);
    }
Esempio n. 15
0
        private Control createTile(GameColors color)
        {
            var tile = new Button();

            tile.Width  = 100;
            tile.Height = 100;

            tile.Tag        = color;
            tile.Background = getColorByName(color.ToString());

            return(tile);
        }
Esempio n. 16
0
    private void ConsumeShot()
    {
        AudioManager.PlayAudio("Gulp");

        switch (savedShotParams.type)
        {
        case Shot.ShotTypes.ColorShot:
        {
            GameColors newColor = currentColor.Add(savedShotParams.color);

            if (currentColor.IsRivalColor(savedShotParams.color))
            {
                if (savedShotParams.timeToLive > 0)
                {
                    InitiateSpitShot();
                }
            }
            else if (newColor != currentColor)
            {
                Manager.instance.updateScore(currentColor, newColor);
                currentColor = newColor;
                sprite.color = currentColor.GetColor();
                Manager.instance.checkFinish();
            }
        }
        break;

        case Shot.ShotTypes.WhiteShot:
        {
            if (currentColor != GameColors.White)
            {
                Manager.instance.updateScore(currentColor, GameColors.White);
                currentColor = GameColors.White;
                sprite.color = currentColor.GetColor();
            }
        }
        break;

        case Shot.ShotTypes.InstantBlech:
        {
            GameColors newColor = savedShotParams.color;
            Manager.instance.updateScore(currentColor, newColor);
            currentColor = newColor;
            sprite.color = currentColor.GetColor();
            if (savedShotParams.timeToLive > 0)
            {
                InitiateSpitShot();
            }
        }
        break;
        }
    }
Esempio n. 17
0
 public static GameColors Add(this GameColors color, GameColors colorToAdd)
 {
     switch (colorToAdd) {
     case GameColors.Blue:
         return color.AddBlue ();
     case GameColors.Red:
         return color.AddRed ();
     case GameColors.Yellow:
         return color.AddYellow ();
     default:
         return color;
     }
 }
Esempio n. 18
0
        private void tileClicked(object sender, RoutedEventArgs e)
        {
            var        button    = (Button)sender;
            GameColors tileColor = (GameColors)button.Tag;

            if (tileColor != correctColor)
            {
                playerLoose();
            }
            else
            {
                correctAnswer(button);
            }
        }
Esempio n. 19
0
 /*!
 * \fn String colorTypeToString(GameColors i)
 * \brief Donne la chaine de caractere correspondante a un type de couleur
 * \param GameColors i le type de couleur dont on veut le nom
 * \return String le nom de la couleur donnee en parametre
 */
 public static String colorTypeToString(GameColors i)
 {
     switch (i)
     {
         case GameColors.Red:
             return "Red";
         case GameColors.Blue:
             return "Blue";
         case GameColors.Green:
             return "Green";
         case GameColors.Yellow:
             return "Yellow";
         default:
             return "Color problem";
     }
 }
Esempio n. 20
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("ColorChange")) {
         var colo = other.GetComponent<ColorChanger>();
         spriter.sprite = colo.CharacterColor;
         ColorChange = colo.NewColor;
         gameColor = colo.gameColor;
     }
     if (other.CompareTag("PieceChanged") && ColorChange != null) {
         var piece = other.GetComponent<SpriteRenderer>();
         var piecee = other.GetComponent<Piece>();
         piece.sprite = ColorChange;
         GameManager.gameManager.ColorChange(gameColor,piecee.gameColor);
         piecee.gameColor = gameColor;
     }
 }
Esempio n. 21
0
        private void setGameZone(GameZone gameZone)
        {
            countCorrectAnswers = 0;
            currentGameZone     = gameZone;

            GameZonePanel.Children.Clear();

            correctColor             = gameZone.CorrectColor;
            correctColorControl.Fill = getColorByName(correctColor.ToString());

            foreach (var tile in gameZone.GameTiles)
            {
                GameZonePanel.Children.Add(createTile(tile.Color));
            }

            GameTimer.ExecuteWithDelay(new Action(flipTiles), TimeSpan.FromSeconds(PREVIEW_TIME));
        }
Esempio n. 22
0
    private void CreateColumn(Vector3Int pos, int col)
    {
        GameObject   newChild = GameObject.Instantiate(columnPrefab, transform);
        MeshRenderer topRend;

        newChild.transform.position = pos;
        Transform[] childs = newChild.GetComponentsInChildren <Transform>();
        for (int i = 0; i < childs.Length; i++)
        {
            if (childs[i].name == "Top")
            {
                topRend = childs[i].GetComponent <MeshRenderer>();
                topRend.material.color = GameColors.GetColor(col);
                break;
            }
        }
    }
Esempio n. 23
0
    public static GameColors Add(this GameColors color, GameColors colorToAdd)
    {
        switch (colorToAdd)
        {
        case GameColors.Blue:
            return(color.AddBlue());

        case GameColors.Red:
            return(color.AddRed());

        case GameColors.Yellow:
            return(color.AddYellow());

        default:
            return(color);
        }
    }
Esempio n. 24
0
    public static GameColors AddBlue(this GameColors color)
    {
        switch (color)
        {
        case GameColors.White:
            return(GameColors.Blue);

        case GameColors.Red:
            return(GameColors.Purple);

        case GameColors.Yellow:
            return(GameColors.Green);

        default:
            return(color);
        }
    }
Esempio n. 25
0
    public static GameColors AddRed(this GameColors color)
    {
        switch (color)
        {
        case GameColors.White:
            return(GameColors.Red);

        case GameColors.Blue:
            return(GameColors.Purple);

        case GameColors.Yellow:
            return(GameColors.Orange);

        default:
            return(color);
        }
    }
Esempio n. 26
0
    public static GameColors AddYellow(this GameColors color)
    {
        switch (color)
        {
        case GameColors.White:
            return(GameColors.Yellow);

        case GameColors.Blue:
            return(GameColors.Green);

        case GameColors.Red:
            return(GameColors.Orange);

        default:
            return(color);
        }
    }
    public static void SetTeamColors()
    {
        TeamData[]    teams      = Tools.GetAtFolder <TeamData>("Data/Teams");
        GameColors    gameColors = (GameColors)Tools.GetFile <GameColors>("Data/Misc/GameColors.asset");
        List <Color>  availableColors;
        List <string> modifiedTeams = new List <string>();


        foreach (TeamData team in teams)
        {
            availableColors = new List <Color>(gameColors.TeamColors);
            if (!availableColors.Contains(team.PrimaryColor))
            {
                team.PrimaryColor = availableColors[Random.Range(0, availableColors.Count - 1)];
                modifiedTeams.Add(team.Name);
                EditorUtility.SetDirty(team);
            }

            if (!availableColors.Contains(team.SecondaryColor) || team.SecondaryColor == team.PrimaryColor)
            {
                availableColors.Remove(team.PrimaryColor);
                team.SecondaryColor = availableColors[Random.Range(0, availableColors.Count - 1)];
                if (!modifiedTeams.Contains(team.Name))
                {
                    modifiedTeams.Add(team.Name);
                }
                EditorUtility.SetDirty(team);
            }
        }

        if (modifiedTeams.Count > 0)
        {
            string output = "TEAMS MODIFIED: \n\n";
            foreach (string teamName in modifiedTeams)
            {
                output += teamName + "\n";
            }
            EditorUtility.DisplayDialog("Team Colors Updated", output, "AUXTERLIBRE!");
        }
        else
        {
            EditorUtility.DisplayDialog("Zero Team Colors Updated", "No teams needed to have their colors changed. Good job!", "AUXTERLIBRE!");
        }

        AssetDatabase.SaveAssets();
    }
Esempio n. 28
0
    //called when game ends
    void finish(GameColors winningColor)
    {
        isFinished = true;

        //fireworks
        for (int i = 0; i < 3; i++)
        {
            GameObject winEffect = Instantiate(winningAnimation);
            winEffect.transform.position = new Vector3(Random.Range(-1, 1), Random.Range(-1, 1), 1);
        }

        //text and continue button
        winningText.text = (winningColor.ToString() + " wins!");


        endPanel.SetActive(true);
    }
Esempio n. 29
0
    void shoot(Vector3 dir, int intType, int intColor, int timeToLive)
    {
        if (debugPrints)
        {
            print("Shooot!");
        }
        Shot.ShotTypes type   = (Shot.ShotTypes)intType;
        GameColors     color  = (GameColors)intColor;
        GameObject     myShot = (GameObject)Instantiate(shot);

        myShot.GetComponent <Shot> ().InitShot(new Shot.ShotParams(type, color, timeToLive));
        var shotRigidBody = myShot.GetComponent <Rigidbody> ();

        shotRigidBody.transform.position = this.transform.position + mozzleOffset;
        shotRigidBody.velocity           = dir;
        Manager.instance.updateTurn();
    }
Esempio n. 30
0
        public GameCell(double size)
        {
            _fontInitialSize = size / 2;
            InputTransparent = true;
            BackgroundColor  = GameColors.GetTileBackgroundColor(0);

            //WidthRequest = HeightRequest = size;
            _label = new Label
            {
                FontAttributes    = FontAttributes.Bold,
                TextColor         = Color.White,
                FontSize          = GetFontSize(string.Empty),
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };

            Children.Add(_label);
        }
Esempio n. 31
0
        public static void MakeBackgroundColor(GameColors color)
        {
            ConsoleColor consoleColor = ConsoleColor.Black;

            switch (color)
            {
            case GameColors.None:
                break;

            case GameColors.Red:
                consoleColor = ConsoleColor.Red;
                break;

            case GameColors.Cyan:
                consoleColor = ConsoleColor.Cyan;
                break;

            case GameColors.Grey:
                consoleColor = ConsoleColor.Gray;
                break;

            case GameColors.Green:
                consoleColor = ConsoleColor.Green;
                break;

            case GameColors.White:
                consoleColor = ConsoleColor.White;
                break;

            case GameColors.Yellow:
                consoleColor = ConsoleColor.Yellow;
                break;

            case GameColors.DarkGrey:
                consoleColor = ConsoleColor.DarkGray;
                break;

            default:
                break;
            }

            Console.BackgroundColor = consoleColor;
        }
Esempio n. 32
0
 public Formation(Game game, int numEnemies, Vector3 startPoint)
     : base(game)
 {
     this.startPoint = startPoint;
     enemies = new List<Enemy>(numEnemies);
     velocities = new List<Vector3>();
     if (NarlyGame.difficulty == NarlyGame.Difficulty.Easy)
     {
         color = Utility.RandomEnum<GameColors>(2);
     }
     else if (NarlyGame.difficulty == NarlyGame.Difficulty.Medium)
     {
         color = Utility.RandomEnum<GameColors>(3);
     }
     else
     {
         color = Utility.RandomEnum<GameColors>();
     }
 }
Esempio n. 33
0
        protected override void OnRender(ChromaCanvas canvas)
        {
            var enteredHyperspace = Game.FsdJumpType == FsdJumpType.Hyperspace;
            var changed           = enteredHyperspace != _enteredHyperspace;

            _enteredHyperspace = enteredHyperspace;

            var enteredNow = changed && enteredHyperspace;
            var exitedNow  = changed && !enteredHyperspace;

            if (enteredNow)
            {
                _starClassColor = GameColors.GetStarClassColor(Game.FsdJumpStarClass);
                return;
            }

            if (exitedNow)
            {
                StartAnimation();
            }

            if (!Animated)
            {
                return;
            }

            if (AnimationElapsed >= _flashTotalLength)
            {
                StopAnimation();
                return;
            }

            var cKey = PulseColor(Game.Colors.Hud.Transform(Colors.KeyboardDimBrightness), _starClassColor, _flashTotalLength);
            var cDev = PulseColor(Game.Colors.Hud.Transform(Colors.DeviceDimBrightness), _starClassColor, _flashTotalLength);

            canvas.Keyboard.Max(cKey);
            canvas.Mouse.Max(cDev);
            canvas.Mousepad.Max(cDev);
            canvas.Keypad.Max(cKey);
            canvas.Headset.Max(cDev);
            canvas.ChromaLink.Max(cDev);
        }
Esempio n. 34
0
    // Use this for initialization
    void Start()
    {
        _animator = GetComponent <Animator>();

        if (gameObject.name.Contains("White"))
        {
            _color = GameColors.White;
            _key   = "q";
        }
        else if (gameObject.name.Contains("Blue"))
        {
            _color = GameColors.Blue;
            _key   = "w";
        }
        else if (gameObject.name.Contains("Black"))
        {
            _color = GameColors.Black;
            _key   = "e";
        }
    }
Esempio n. 35
0
        public enum GameStatusType { WaitType, MoveType, ShootType };            /*!< Les etats (GameStatus) utilises */

        /*!
         * \fn String colorTypeToString(GameColors i)
         * \brief Donne la chaine de caractere correspondante a un type de couleur
         * \param GameColors i le type de couleur dont on veut le nom
         * \return String le nom de la couleur donnee en parametre
         */
        public static String colorTypeToString(GameColors i)
        {
            switch (i)
            {
            case GameColors.Red:
                return("Red");

            case GameColors.Blue:
                return("Blue");

            case GameColors.Green:
                return("Green");

            case GameColors.Yellow:
                return("Yellow");

            default:
                return("Color problem");
            }
        }
Esempio n. 36
0
 public Brush GetColorFromGameColors(GameColors color)
 {
     switch (color)
     {
         case GameColors.Blue:
             return Brushes.Blue;
         case GameColors.Brown:
             return Brushes.Brown;
         case GameColors.Green:
             return Brushes.Green;
         case GameColors.Purple:
             return Brushes.Purple;
         case GameColors.Red:
             return Brushes.Red;
         case GameColors.Yellow:
             return Brushes.Yellow;
         default:
             throw new ArgumentException("Invalid color " + color.ToString());
     }
 }
Esempio n. 37
0
    //    private float time = 0;
    protected void Update()
    {
        if (iShoot) {
        //			time += Time.deltaTime;
        //			if (time > 1) {
        //				time = 0;
        //				CalculateSpitDirections ();
        //				SpitShot (new Shot.ShotParams ());
        //			}

            currentColor = GameColors.Purple;
            EatColor (new Shot.ShotParams (Shot.ShotTypes.ColorShot, GameColors.Yellow, 2));
            iShoot = false;
        }

        timeTillIdle += Time.deltaTime;
        if (timeTillIdle > nextIdleTime) {
            int trigger = Random.value > 0.5 ? IDLE_1_TRIGGER : IDLE_2_TRIGGER;
            animator.SetTrigger (trigger);
            nextIdleTime = Random.Range (idleMinTime, idleMaxTime);
            timeTillIdle = 0;
        }
    }
Esempio n. 38
0
        public ShotParams()
        {
            if (rand == null)
            {
                rand = new System.Random();
            }
            float sumW = 0;

            foreach (var item in shotTypeWeights)
            {
                type  = item.Key;
                sumW += item.Value;
            }
            int   typeIndex = (int)(rand.NextDouble() * sumW);
            float currW     = 0;

            foreach (var item in shotTypeWeights)
            {
                currW += item.Value;
                if (typeIndex < currW)
                {
                    type = item.Key;
                    break;
                }
            }

            color = possibleColors [(int)(UnityEngine.Random.value * possibleColors.Length)];
            if (type == ShotTypes.InstantBlech)
            {
                timeToLive = 1;
            }
            else
            {
                timeToLive = 2;
            }
        }
Esempio n. 39
0
    public void updateScore(GameColors prevColor, GameColors newColor)
    {
        if (prevColor == GameColors.Green) {
            numGreen--;
        } else if (prevColor == GameColors.Purple) {
            numPurple--;
        } else if (prevColor == GameColors.Orange) {
            numOrange--;
        }

        if (newColor == GameColors.Green) {
            numGreen++;
        } else if (newColor == GameColors.Purple) {
            numPurple++;
        } else if (newColor == GameColors.Orange) {
            numOrange++;
        }

        int numMixed = Mathf.Max(1, numGreen + numPurple + numOrange) ;

        greenScoreSlider.value = (float)(numGreen) / numMixed;
        purpleScoreSlider.value = (float)(numPurple) / numMixed;
        orangeScoreSlider.value = (float)(numOrange) / numMixed;
    }
Esempio n. 40
0
    //called when game ends
    void finish(GameColors winningColor)
    {
        isFinished = true;

        //fireworks
        for (int i = 0; i < 3; i++) {
            GameObject winEffect = Instantiate (winningAnimation);
            winEffect.transform.position = new Vector3(Random.Range(-1, 1), Random.Range(-1, 1), 1);
        }

        //text and continue button
        winningText.text = (winningColor.ToString() + " wins!");

        endPanel.SetActive(true);
    }
Esempio n. 41
0
 public Card(GameColors _color)
 {
     Color = _color;
 }
Esempio n. 42
0
 public static Color GetSystemColor(GameColors gameColor)
 {
     return colors[(int)gameColor];
 }
Esempio n. 43
0
        public ShotParams()
        {
            if (rand == null)
            {
                rand = new System.Random();
            }
            float sumW = 0;
            foreach (var item in shotTypeWeights)
            {
                type = item.Key;
                sumW += item.Value;
            }
            int typeIndex = (int)(rand.NextDouble() * sumW);
            float currW = 0;
            foreach (var item in shotTypeWeights)
            {
                currW += item.Value;
                if (typeIndex < currW)
                {
                    type = item.Key;
                    break;
                }
            }

            color = possibleColors [(int)(UnityEngine.Random.value * possibleColors.Length)];
            if (type == ShotTypes.InstantBlech)
            {
                timeToLive = 1;
            }
            else
            {
                timeToLive = 2;
            }
        }
Esempio n. 44
0
 Projectile(Game game, GameColors color)
     : base(game)
 {
     this.GameColor = color;
 }
Esempio n. 45
0
 public static bool IsRivalColor(this GameColors color, GameColors otherColor)
 {
     return (color == GameColors.Green && otherColor == GameColors.Red) ||
         (color == GameColors.Orange && otherColor == GameColors.Blue) ||
         (color == GameColors.Purple && otherColor == GameColors.Yellow);
 }
Esempio n. 46
0
        public override void Update(GameTime gameTime)
        {
            foreach (var particle in particles)
            {
                particle.SetCamera(camera.View, camera.Projection);
                particle.Update(gameTime);
            }

            Laser = null;

            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
            KeyboardState keyboardState = Keyboard.GetState();
            GamePadState gamePadState = GamePad.GetState(ControllingPlayer);

            // Narly death code ===================================================
            if (keyboardState.IsKeyDown(Keys.Z))
            {
                health -= 0.03f;//temp for testing
            }

            // Handle Narly death
            if (health <= 0)
            {
                //Hack to make the reticle disappear when we're dead
                reticle.Destination = new Vector3(9001, 9001, 9001);
                reticle.Source = new Vector3(9001, 9001, 9001);

                // Narly is dead.  Do something smart!
                time = time + elapsedTime;
                if (time < 0.3f)
                {
                    scaleFactor = (1.00f + (0.3f - time) / 10) * scaleFactor;
                }
                else if (scaleFactor > 0.05f)
                {
                    //scaleFactor =  0.95f * scaleFactor;
                    scaleFactor = (1.00f - (time - 0.3f) / 10) * scaleFactor;

                }
                else
                {
                    dead = true; //stops the model from drawing

                }
                Matrix.CreateScale(scaleFactor, out scale);

                return; //Don't update input, color change, anything else

            }
            // End Narly death code  ===============================================

            // Begin color changing code =======================================================
            if (transitioningUp)
            {
                time = Math.Min(duration, time + elapsedTime);
                //color = new Color((Color.White.ToVector3() - color.ToVector3()) * time / duration + color.ToVector3());
                color = new Color((Color.White.ToVector3() - color.ToVector3()) * time / duration + color.ToVector3());
                if (time >= duration)
                {
                    transitioningUp = false;
                    transitioningDown = true;
                    gameColor = transitionToGameColor;
                }

                NarlyGame.rumble.colorRumbleTimer = 0.10f;
            }
            else if (transitioningDown)
            {
                color = new Color((GameColorsUtilities.GetSystemColor(transitionToGameColor).ToVector3() - color.ToVector3()) * (duration - time) / duration + color.ToVector3());
                time = Math.Max(0.0f, time - elapsedTime);
                if (time <= 0.0f)
                {
                    transitioningDown = false;
                }
            }
            else if (keyboardState.IsKeyDown(Keys.Down) || gamePadState.Buttons.A == ButtonState.Pressed)
            {
                transitioningUp = true;
                transitionToGameColor = GameColors.Green;
            }
            else if (keyboardState.IsKeyDown(Keys.Right) || gamePadState.Buttons.B == ButtonState.Pressed)
            {
                transitioningUp = true;
                transitionToGameColor = GameColors.Red;
            }
            else if (keyboardState.IsKeyDown(Keys.Up) || gamePadState.Buttons.Y == ButtonState.Pressed)
            {
                transitioningUp = true;
                transitionToGameColor = GameColors.Yellow;
            }
            else if (keyboardState.IsKeyDown(Keys.Left) || gamePadState.Buttons.X == ButtonState.Pressed)
            {
                transitioningUp = true;
                transitionToGameColor = GameColors.Blue;

            }

            // End color changing code ===============================================

            // Narly movement code ===================================================
            UpdateDestination(gameTime);

            // Lock player to screen
            screenPoint.Z = 0.997f;
            screenPoint.X = MathHelper.Clamp(screenPoint.X,
                screenEdgeBuffer, Game.GraphicsDevice.PresentationParameters.BackBufferWidth - screenEdgeBuffer);
            screenPoint.Y = MathHelper.Clamp(screenPoint.Y,
                screenEdgeBuffer, Game.GraphicsDevice.PresentationParameters.BackBufferHeight - screenEdgeBuffer);
            destination.Z = 1.0f;
            destination.X = MathHelper.Clamp(destination.X,
                screenEdgeBuffer, Game.GraphicsDevice.PresentationParameters.BackBufferWidth - screenEdgeBuffer);
            destination.Y = MathHelper.Clamp(destination.Y,
                screenEdgeBuffer, Game.GraphicsDevice.PresentationParameters.BackBufferHeight - screenEdgeBuffer);

            farPoint = GraphicsDevice.Viewport.Unproject(destination,
                camera.Projection, camera.View, Matrix.Identity);
            Position = GraphicsDevice.Viewport.Unproject(screenPoint,
                camera.Projection, camera.View, Matrix.Identity);

            direction = farPoint - Position;

            float speed = 1.0f;
            Vector3.Multiply(ref direction, (float)(gameTime.ElapsedGameTime.TotalSeconds * speed), out direction);

            Vector3 tempPosition = Position;
            tempPosition.Y += direction.Y;
            tempPosition.X += direction.X;
            Position = tempPosition;

            // End movement code =====================================================

            // Reticle code ==========================================================
            screenPoint = GraphicsDevice.Viewport.Project(Position, camera.Projection, camera.View, Matrix.Identity);
            //position.Z = 0.8f;

            reticle.Destination = destination;
            reticle.Source = screenPoint;

            // End reticle code ======================================================

            Vector3.Multiply(ref direction, 200.0f, out direction);

            if (gamePadState.IsButtonDown(Buttons.RightTrigger))
            {
                firing = true;
                Fire(gameTime);
            }
            else
            {
                firing = false;
            }

            ////////////Starwhal effects/////////////////
            if (gamePadState.IsButtonDown(Buttons.LeftTrigger) && starwhalPower >= 1.0f)
            {
                starwhalPowerActive = true;
            }
            if (starwhalPowerActive)
            {
                NarlyGame.rumble.damageRumbleTimer = 0.01f;

                color = TextEffects.GetShiftingColor();

                if (direction.X <= 0 && barrelRollSpeed <= 0.2f)
                {
                    barrelRollSpeed += 0.05f;
                }
                else if (barrelRollSpeed >= -0.2f)
                {
                    barrelRollSpeed -= 0.05f;
                }
                barrelRollAngle += barrelRollSpeed;

                starwhalPower -= 0.1f * elapsedTime;    // Starwhal power lasts 10 seconds
                if (starwhalPower <= 0)
                {
                    starwhalPowerActive = false;
                    starwhalPower = 0;
                    color = GameColorsUtilities.GetSystemColor(gameColor);

                    while (barrelRollAngle > 2 * MathHelper.Pi)
                    { barrelRollAngle -= 2 * MathHelper.Pi; }
                    while (barrelRollAngle < -2 * MathHelper.Pi)
                    { barrelRollAngle += 2 * MathHelper.Pi; }
                }
            }
            else
            {
                barrelRollSpeed = 0;
                barrelRollAngle *= 0.9f;
            }

            if (takingDamage)
            {
                float colorShift = (float)(1 - 0.6 * Math.Abs(Math.Sin(20 * damageRollCounter)));
                color.R = (byte)(GameColorsUtilities.GetSystemColor(gameColor).R * colorShift);
                color.G = (byte)(GameColorsUtilities.GetSystemColor(gameColor).G * colorShift);
                color.B = (byte)(GameColorsUtilities.GetSystemColor(gameColor).B * colorShift);
                if (damageRollCounter < 0.75f)
                {
                    damageRollCounter += elapsedTime;
                    damageRollAngle = (float)(0.5 * Math.Sin(20 * damageRollCounter));
                }
                else
                {
                    color = GameColorsUtilities.GetSystemColor(gameColor);
                    takingDamage = false;
                    damageRollCounter = 0;
                }
            }
            else
            {
                damageRollAngle *= 0.9f; // settle back to 0
            }

            //////////////////////////////////////////

            for (int i = 0; i < particleEmitter.Count(); ++i)
            {
                particles[i].On = Laser != null;
                float lerp = (float)i / particleEmitter.Count();
                Vector3 particlePosition = new Vector3(
                    MathHelper.Lerp(Position.X, farPoint.X, lerp),
                    MathHelper.Lerp(Position.Y, farPoint.Y, lerp),
                    MathHelper.Lerp(Position.Z, farPoint.Z, lerp));
                particleEmitter[i].Update(gameTime, particlePosition);
            }

            base.Update(gameTime);
        }
Esempio n. 47
0
 public void RemoveColor(GameColors color)
 {
     _currentColors = _currentColors & ~color;
     onCurrentColorsChanged();
 }
Esempio n. 48
0
 public Tile(int x, int y, GameColors color)
 {
     GridX = x;
     GridY = y;
     Color = color;
 }
Esempio n. 49
0
    private void ConsumeShot()
    {
        AudioManager.PlayAudio ("Gulp");

        switch (savedShotParams.type) {
        case Shot.ShotTypes.ColorShot:
            {
                GameColors newColor = currentColor.Add (savedShotParams.color);

                if (currentColor.IsRivalColor (savedShotParams.color)) {
                    if (savedShotParams.timeToLive > 0) {
                        InitiateSpitShot ();
                    }
                } else if (newColor != currentColor) {
                    Manager.instance.updateScore (currentColor, newColor);
                    currentColor = newColor;
                    sprite.color = currentColor.GetColor ();
                    Manager.instance.checkFinish ();

                }
            }
            break;
        case Shot.ShotTypes.WhiteShot:
            {
                if (currentColor != GameColors.White) {
                    Manager.instance.updateScore (currentColor, GameColors.White);
                    currentColor = GameColors.White;
                    sprite.color = currentColor.GetColor ();
                }
            }
            break;
        case Shot.ShotTypes.InstantBlech:
            {
                GameColors newColor = savedShotParams.color;
                Manager.instance.updateScore (currentColor, newColor);
                currentColor = newColor;
                sprite.color = currentColor.GetColor ();
                if (savedShotParams.timeToLive > 0) {
                    InitiateSpitShot ();
                }
            }
            break;
        }
    }
Esempio n. 50
0
 public ShotParams(ShotTypes type, GameColors color, int timeToLive)
 {
     this.type = type;
     this.color = color;
     this.timeToLive = timeToLive;
 }
Esempio n. 51
0
        public static Enemy Create(Game game, GameColors gameColor)
        {
            released = false;
            if (unusedEnemies[(int)gameColor] == null)
            {
                unusedEnemies[(int)gameColor] = new Queue<Enemy>();
            }
            else if (unusedEnemiesToRelease[(int)gameColor] != null)
            {
                foreach (var enemy in unusedEnemiesToRelease[(int)gameColor])
                {
                    if (enemy.ToRelease)
                    {
                        unusedEnemies[(int)gameColor].Enqueue(enemy);
                    }
                    else
                    {
                        enemy.ToRelease = true;
                    }
                }
                unusedEnemiesToRelease[(int)gameColor] = (from enemy in unusedEnemiesToRelease[(int)gameColor]
                                                        where !enemy.ToRelease
                                                        select enemy).ToList();
            }

            if (unusedEnemies[(int)gameColor].Count > 0)
            {
                Enemy enemy = unusedEnemies[(int)gameColor].Dequeue();
                enemy.renderColor = GameColorsUtilities.GetSystemColor(gameColor);
                enemy.IsAlive = true;
                enemy.particleSystem.On = false;
                enemy.IsDying = false;
                enemy.enteredScreen = false;
                enemy.lastVelocity = Vector3.Zero;
                enemy.health = 5;
                enemy.time = 0;
                enemy.timeToFire = 0;
                enemy.takingDamage = false;
                enemy.damageRollAngle = 0;
                enemy.damageRollAngle2 = 0;
                enemy.damageRollCounter = 0;
                enemy.position = Vector3.Zero;
                enemy.ToRelease = false;
                return enemy;
            }
            else
            {
                Enemy enemy = new Enemy(game, gameColor);
                enemy.Initialize();
                return enemy;
            }
        }
Esempio n. 52
0
 public void KilledEnemy(GameColors gameColor)
 {
     int points = (int)(100 * health);
     if (!starwhalPowerActive && gameColor != this.gameColor)
     {
         points *= 2;
     }
     else if (starwhalPowerActive)
     {
         points *= 4;
     }
     NarlyGame.score += points;
 }
Esempio n. 53
0
 protected override void LoadContent()
 {
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     _colors = new GameColors();
     _patterns = new GamePatterns();
     _imageDescriptors = new GameImageDescriptors();
     _images = new Images(GraphicsDevice, _colors, _patterns);
     _imageRenderer = new ImageRenderer(_imageDescriptors, _images, _spriteBatch);
     _gameController = new GameController(this,_imageRenderer);
     _previousKeyboardState = Keyboard.GetState();
     _players.ToList().ForEach(x => _previousGamePadState[x] = GamePad.GetState(x));
 }
Esempio n. 54
0
        public Player(Game game, PlayerIndex player)
            : base(game)
        {
            //starwhalPowerActive = false;
            //barrelRollAngle = 0;
            //barrelRollSpeed = 0;

            //takingDamage = false;
            //damageRollAngle = 0;
            //damageRollCounter = 0;

            ControllingPlayer = player;
            sphereOffset = new Vector3(0.0f, 0.0f, 45.0f * scaleFactor);

            gameColor = GameColors.Red;
            color = Color.Red;
            reticle = new Reticle(Game);
            Game.Components.Add(reticle);
            destination = new Vector3(0.5f * Game.GraphicsDevice.PresentationParameters.BackBufferWidth,
                0.5f * Game.GraphicsDevice.PresentationParameters.BackBufferHeight, 1.0f);
            Game.Services.AddService(typeof(IPlayer), this);
        }
Esempio n. 55
0
    public static GameColors[] getPrimaries(this GameColors color)
    {
        GameColors[] primaries;

        if (color == GameColors.Green)
        {
            primaries = new GameColors[2] { GameColors.Blue, GameColors.Yellow };
        }
        else if (color == GameColors.Purple)
        {
            primaries = new GameColors[2] { GameColors.Blue, GameColors.Red };
        }
        else if (color == GameColors.Orange)
        {
            primaries = new GameColors[2] { GameColors.Yellow, GameColors.Red };
        }
        else
        {
            primaries = new GameColors[1] { color };
        }

        return primaries;
    }