Esempio n. 1
0
    protected override void AddColour(CharacterColour colour)
    {
        if (IsComplete)
        {
            return;
        }

        Received.Add(colour);

        // If we have the correct number of elements in buffer then check combination
        if (Received.Count == combination.Length)
        {
            for (int i = 0; i < combination.Length; i++)
            {
                // Incorrect combination
                if (Received[i] != combination[i])
                {
                    // Clear the received buffer
                    Received.Clear();
                    // Play a failure sound?
                    return;
                }
            }

            // Combination was correct
            SetComplete();
        }
    }
    protected override void Start()
    {
        base.Start();
        requiredNumActivations = platforms.Length;
        foreach (Platform platform in platforms)
        {
            // Subscribe to platform activation events
            platform.onActivation += UpdateActivated;

            // If the platform is inactive it's not required
            if (!platform.gameObject.activeInHierarchy)
            {
                requiredNumActivations -= 1;
            }
        }

        // Randomize colours of interactables
        if (platforms.Length == rocks.Length)
        {
            for (int i = 0; i < platforms.Length; i++)
            {
                CharacterColour colour = playerColours[Random.Range(0, playerColours.Length)];
                platforms[i].colour = colour;
                rocks[i].colour     = colour;
                platforms[i].SetMaterial(colour);
                rocks[i].SetMaterialColour(colour);
            }
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Set the texture and highlight materials for the enemy based on a character colour
    /// </summary>
    /// <param name="colour">Character colour to base colour assignment decision on</param>
    public void AssignEnemyColour(CharacterColour colour)
    {
        characterColour = colour;
        SkinnedMeshRenderer skin = GetComponentInChildren <SkinnedMeshRenderer>();
        Material            skinMaterial;

        switch (colour)
        {
        case CharacterColour.Red:
            skinMaterial = EnemyColouring.Red;
            break;

        case CharacterColour.Yellow:
            skinMaterial = EnemyColouring.Yellow;
            break;

        case CharacterColour.Green:
            skinMaterial = EnemyColouring.Green;
            break;

        case CharacterColour.Blue:
            skinMaterial = EnemyColouring.Blue;
            break;

        default:
            skinMaterial = EnemyColouring.Default;
            break;
        }

        if (skinMaterial)
        {
            skin.material = skinMaterial;
        }
    }
Esempio n. 4
0
 public Player(PlayerInput _playerInput, CharacterColour _characterColour, CharacterOption _characterChoice, int _deviceId)
 {
     playerInput     = _playerInput;
     characterColour = _characterColour;
     characterChoice = _characterChoice;
     deviceId        = _deviceId;
 }
    public override void SetMaterialColour(CharacterColour colour)
    {
        Renderer renderer = GetComponentInChildren <Renderer>();
        Material material;

        switch (colour)
        {
        case CharacterColour.Blue:
            material = blueMaterial;
            break;

        case CharacterColour.Green:
            material = greenMaterial;
            break;

        case CharacterColour.Red:
            material = redMaterial;
            break;

        case CharacterColour.Yellow:
            material = yellowMaterial;
            break;

        default:
            material = defaultMaterial;
            break;
        }

        renderer.material = material;
    }
Esempio n. 6
0
        private static Character CreateCharacter(CharacterColour colour, CharacterClass cClass)
        {
            var character = new Character(Guid.NewGuid(), colour, cClass)
            {
                OwnerPlayerId = ApplicationData.PlayerId,
                Name          = NameMapper.Instance.GetRandom()
            };

            character.InitializeDefaultDeck();
            return(character);
        }
Esempio n. 7
0
    /// <summary>
    /// Assign a random colour to the enemy
    /// </summary>
    /// <returns>An IEnumerator</returns>
    protected IEnumerator AssignRandomColour()
    {
        // Get a colour that is used by a registered player
        CharacterColour randomColour = PlayerManager.playerColours[Random.Range(0, PlayerManager.playerColours.Count)];

        // keep choosing a random colour until a different one is chosen
        while (randomColour == characterColour)
        {
            randomColour = PlayerManager.playerColours[Random.Range(0, PlayerManager.playerColours.Count)];
        }
        // Assign the enemy colour
        AssignEnemyColour(randomColour);
        yield return(null);
    }
Esempio n. 8
0
    /// <summary>
    /// Register a player
    /// </summary>
    /// <param name="player">Player gameobject</param>
    public static void RegisterPlayer(GameObject player)
    {
        Players.Add(player);
        // assign the player a colour as soon as they're registered
        CharacterColour characterColour = player.GetComponent <EntityStatsController>().characterColour;

        if (characterColour == CharacterColour.None)
        {
            // if they don't have a colour, give them one
            characterColour = availableColours[0];
            availableColours.Remove(characterColour);
        }
        playerColours.Add(characterColour);
        player.GetComponent <EntityStatsController>().characterColour = characterColour;
    }
Esempio n. 9
0
    public Color GetColour(CharacterColour colour)
    {
        switch (colour)
        {
        case CharacterColour.Red: return(red);

        case CharacterColour.Green: return(green);

        case CharacterColour.Blue: return(blue);

        case CharacterColour.Yellow: return(yellow);

        default: return(Color.gray);
        }
    }
    /// <summary>
    /// Take damage from a coloured orb in the final boss fight
    /// </summary>
    /// <param name="orbColour">The colour of the orb which is dealing damage</param>
    public void TakeDamageFromOrb(CharacterColour orbColour)
    {
        if (!OrbsRequired.Contains(orbColour))
        {
            return;
        }

        // Take enough damage such that the boss will be at half health for phase 2
        float hitValue = (1f / PlayerManager.Instance.NumPlayers) * 0.5f * health.maxValue;

        health.Subtract(hitValue);
        ShowDamage(hitValue);

        // Remove the orb colour from the list of colours still required
        OrbsRequired.Remove(orbColour);
    }
    /// <summary>
    /// Set the material of the platform to reflect the assigned character colour
    /// </summary>
    public void SetMaterial(CharacterColour colour)
    {
        Renderer renderer = GetComponent <Renderer>();

        Material[] materials = new Material[1];
        Material   material  = new Material(Shader.Find("Legacy Shaders/Particles/Additive"));
        Texture    texture;
        Color      tintColor;

        ;       switch (colour)
        {
        case CharacterColour.Blue:
            texture   = blueMaterial.GetTexture("_MainTex");
            tintColor = blueMaterial.GetColor("_TintColor");
            break;

        case CharacterColour.Green:
            texture   = greenMaterial.GetTexture("_MainTex");
            tintColor = greenMaterial.GetColor("_TintColor");
            break;

        case CharacterColour.Red:
            texture   = redMaterial.GetTexture("_MainTex");
            tintColor = redMaterial.GetColor("_TintColor");
            break;

        case CharacterColour.Yellow:
            texture   = yellowMaterial.GetTexture("_MainTex");
            tintColor = yellowMaterial.GetColor("_TintColor");
            break;

        default:
            texture   = defaultMaterial.GetTexture("_MainTex");
            tintColor = defaultMaterial.GetColor("_TintColor");
            break;
        }
        material.SetTexture("_MainTex", texture);
        material.SetColor("_TintColor", tintColor);
        materials[0]       = material;
        renderer.materials = materials;

        // Tint color turns to white if this isn't here
        gameObject.SetActive(false);
        gameObject.SetActive(true);
    }
 private void Start()
 {
     CharacterColour[] playerColours = PlayerManager.Instance.CurrentPlayerColours;
     if (playerColours.Contains(colour))
     {
         // Set the material colour of the platform
         SetMaterial(colour);
     }
     else if (colour == CharacterColour.None)
     {
         colour = playerColours[Random.Range(0, playerColours.Length)];
         SetMaterial(colour);
     }
     else
     {
         // Turn off if object's colour isn't one of the players' colours
         gameObject.SetActive(false);
     }
 }
    /// <summary>
    /// Add a colour to the received colours buffer
    /// </summary>
    /// <param name="colour">Colour to add to the buffer</param>
    protected virtual void AddColour(CharacterColour colour)
    {
        if (IsComplete)
        {
            return;
        }

        // Don't store duplicates of the same colour entry
        if (!Received.Contains(colour))
        {
            Received.Add(colour);
        }

        if (Received.Count == playerColours.Length)
        {
            // All required levers have been pulled
            SetComplete();
        }
    }
    public virtual void SetMaterialColour(CharacterColour characterColour)
    {
        Color color = PlayerManager.colours.GetColour(characterColour);

        Transform[] interactableComponents = GetComponentsInChildren <Transform>();
        float       intensity = 2.0f;

        Material[] materials = new Material[1];
        materials[0] = new Material(Shader.Find("Standard"));
        materials[0].EnableKeyword("_EMISSION");
        materials[0].SetColor("_Color", color);
        materials[0].SetColor("_EmissionColor", color * intensity);
        foreach (Transform interactableComponent in interactableComponents)
        {
            Renderer[] interactableRenderers = interactableComponent.GetComponentsInChildren <Renderer>();
            foreach (Renderer r in interactableRenderers)
            {
                r.materials = materials;
            }
        }
    }
Esempio n. 15
0
    /// <summary>
    /// Sets the colour of the orb to the set colour when enabled
    /// </summary>
    private void OnEnable()
    {
        if (LaunchedByPlayer)
        {
            return;
        }

        // Select an orb colour randomly
        List <CharacterColour> orbColours = (LauncherStats as RhakStatsController).OrbsRequired;

        _colour = orbColours[Random.Range(0, orbColours.Count)];
        Color orbColour = PlayerManager.colours.GetColour(_colour);

        // Set the colour of the particle systems to the orb colour
        foreach (ParticleSystem p in colourParticleSystems)
        {
            VfxHelper.SetParticleSystemColour(p, orbColour);
        }

        // Set interactable colour
        _interactable.colour = _colour;
    }
 protected virtual void Start()
 {
     CharacterColour[] playerColours = PlayerManager.Instance.CurrentPlayerColours;
     if (playerColours.Contains(colour))
     {
         // Set the material colour of the interactable if not a particle system
         if (!isParticleSystem)
         {
             SetMaterialColour(colour);
         }
     }
     else if (colour == CharacterColour.None)
     {
         colour = playerColours[Random.Range(0, playerColours.Length)];
         SetMaterialColour(colour);
     }
     else
     {
         // Turn off if object's colour isn't one of the players' colours
         gameObject.SetActive(false);
     }
 }
Esempio n. 17
0
    protected override void Start()
    {
        playerColours          = PlayerManager.Instance.CurrentPlayerColours;
        requiredNumActivations = platforms.Length;

        // Subscribe to platform activation events
        foreach (Platform platform in platforms)
        {
            platform.onActivation += UpdateActivated;
        }

        // Randomize colours of enemies and platforms
        if (platforms.Length == enemies.Length)
        {
            for (int i = 0; i < platforms.Length; i++)
            {
                CharacterColour colour = playerColours[Random.Range(0, playerColours.Length)];
                platforms[i].colour = colour;
                platforms[i].SetMaterial(colour);
                enemies[i].AssignEnemyColour(colour);
            }
        }
    }
Esempio n. 18
0
    /// <summary>
    /// Set the texture and highlight materials for the enemy based on a character colour
    /// </summary>
    /// <param name="colour">Character colour to base colour assignment decision on</param>
    private void AssignEnemyColour(CharacterColour colour)
    {
        characterColour = colour;
        SkinnedMeshRenderer skin = GetComponentInChildren <SkinnedMeshRenderer>();

        EnemyColouring.ColourVariant enemyColouring;
        switch (colour)
        {
        case CharacterColour.Red:
            enemyColouring = EnemyColouring.Red;
            break;

        case CharacterColour.Yellow:
            enemyColouring = EnemyColouring.Yellow;
            break;

        case CharacterColour.Green:
            enemyColouring = EnemyColouring.Green;
            break;

        case CharacterColour.Purple:
            enemyColouring = EnemyColouring.Purple;
            break;

        default:
            enemyColouring = EnemyColouring.Default;
            break;
        }
        if (!enemyColouring.textureMaterial)
        {
            skin.materials = new Material[] { skin.materials[0], enemyColouring.highlightMaterial };
        }
        else
        {
            skin.materials = new Material[] { enemyColouring.textureMaterial, enemyColouring.highlightMaterial };
        }
    }
Esempio n. 19
0
    public string GetColorHex(CharacterColour colour)
    {
        Color c = GetColour(colour);

        return(string.Format("#{0:X2}{1:X2}{2:X2}", (int)(c.r * 255), (int)(c.g * 255), (int)(c.b * 255)));
    }
Esempio n. 20
0
        private const decimal LastFirstPlayDebuff = 0.5m;           // How much a character is debuffed for damage or healing if they go last in a turn, then go first in a turn.

        public Character(Guid id, CharacterColour colour, CharacterClass characterClass)
        {
            Id             = id;
            CharacterClass = characterClass;
            Colour         = colour;
        }
Esempio n. 21
0
 public string GetSpriteTag(CharacterColour colour, CharacterFacing facing)
 {
     return($"{colour.ToString().ToLower()}_{facing.ToString().ToLower()}");
 }