/**
     * Add a bonus secondary effect
     *
     * Arguments
     * - Effect bonusEffect - The bonus effect to add
     */
    public void AddBonusEffect(Effect bonusEffect)
    {
        int existingIndex; // The index of the existing effect

        if (secondaryEffectRewards.Contains(bonusEffect)) { // Need to handle this
            switch (bonusEffect.GetTurnEffectType()) {
            case TurnEffectType.STATEFFECT: // We are adding a stat effect bonus. Stacking it
                existingIndex = secondaryEffectRewards.IndexOf(bonusEffect);
                if (existingIndex < 0 || existingIndex > (secondaryEffectRewards.Count - 1))
                    throw new System.Exception("Unknown error with alien mode rewards");
                secondaryEffectRewards[existingIndex].SetValue(secondaryEffectRewards[existingIndex].GetValue()
                                                               + bonusEffect.GetValue());
                break;
            case TurnEffectType.COMPONENTEFFECT: // Don't stack
                break;
            }

        } else
            secondaryEffectRewards.Add(bonusEffect);
    }
Exemplo n.º 2
0
    /**
     * Apply a given turn effect
     *
     * Arguments
     * - TurnEffect effect - The turn effect to apply
     */
    void applyTurnEffect(Effect effect)
    {
        Stat stat; // The stat to effect
        int mode; // The mode of this turn effect

        if (effect.TurnsRemaining() == 0) { // Remove turn effect
            DetachTurnEffect(effect);
            return;
        }

        if (effect.IsAppliedPerTurn()) { // Apply per turn
            switch (effect.GetTurnEffectType()) {
            case TurnEffectType.STATMULTIPLIEREFFECT: // Stat multiplier effect
                stat = effect.GetStatAffected();
                mode = effect.GetMode();
                Debug.LogWarning("Stat affected: " + EnumsToString.ConvertStatEnum(stat));
                Debug.LogWarning("Previous value: " + playerClass.GetStat(stat));
                switch (mode) {
                case 0: // Increment
                    playerClass.IncreaseStatMultiplierValue(stat, effect.GetValue());
                    break;
                case 1: // Set stat
                    playerClass.SetMultiplierStat(stat, effect.GetValue());
                    break;
                case 2: // Decrement
                    playerClass.DecreaseStatMultiplierValue(stat, effect.GetValue());
                    break;
                default:
                    throw new System.NotSupportedException("Invalid mode");
                }
                Debug.LogWarning("Current value: " + playerClass.GetStat(stat));
                break;
            case TurnEffectType.STATEFFECT: // Stat effect
                stat = effect.GetStatAffected();
                mode = effect.GetMode();
                Debug.LogWarning("Stat affected: " + EnumsToString.ConvertStatEnum(stat));
                Debug.LogWarning("Previous value: " + stats[stat]);
                switch (mode) {
                case 0: // Increment to stat
                    IncreaseStatValue(stat, effect.GetValue());
                    break;
                case 1: // Set stat
                    SetStatValue(stat, effect.GetValue());
                    break;
                case 2: // Multiply stat
                    SetStatValue(stat, stats[stat] * effect.GetValue());
                    break;
                default: // Invalid mode. Do nothing
                    throw new System.NotSupportedException("Invalid mode");
                }
                Debug.LogWarning("Current value: " + stats[stat]);
                break;
            case TurnEffectType.MATERIALEFFECT:
                // Only replace material if not already set
                if (!PlayerObject.GetComponentInChildren<Renderer>().material.Equals(effect.GetMaterial())) {
                    GetComponent<PhotonView>().RPC("SetNewMaterial", PhotonTargets.All,
                            new object[] {
                                effect.GetMaterialPath()
                            }
                    );
                }
                break;// Change material
            case TurnEffectType.COMPONENTEFFECT: // Component effect. Handled by component
                break;
            default: break; // Unknown
            }
        }

        effect.ReduceTurnsRemaining();
    }
Exemplo n.º 3
0
 /**
  * Attach a single turn effect to this player
  *
  * Arguments
  * - TurnEffect toAdd - Effect to add
  */
 public void AttachTurnEffect(Effect toAdd)
 {
     switch (toAdd.GetTurnEffectType()) { // Apply turn effects immediately if needed
     case TurnEffectType.STATEFFECT: goto default; // Only apply stat effects in the next turn
     case TurnEffectType.MATERIALEFFECT:
         GetComponent<PhotonView>().RPC("SetNewMaterial", PhotonTargets.All,
                 new object[] {
                     toAdd.GetMaterialPath()
                 }
         );
         break;
     case TurnEffectType.ITEMEFFECT: // Apply item effects immediately
         foreach (Item item in inventory) {
             if (item != null)
                 toAdd.ApplyEffectToItem(item);
         }
         break;
     case TurnEffectType.MODELCHANGEEFFECT: goto case TurnEffectType.COMPONENTEFFECT;// Need complex attach routine
     case TurnEffectType.COMPONENTEFFECT: // Need a complex attach routine
         toAdd.ExtraAttachActions();
         break;
     default: break; // Don't do anything
     }
     turnEffects.Add(toAdd);
     effectPanelScript.AddTurnEffect(toAdd);
 }
Exemplo n.º 4
0
 /**
  * Remove a turn effect from this player and revert all its effects on this player
  *
  * Arguments
  * - TurnEffect effect - The turn effect to remove
  */
 public void DetachTurnEffect(Effect effect)
 {
     switch (effect.GetTurnEffectType()) { // Detach the effect on this player depending on type
     case TurnEffectType.STATEFFECT: // Can only reset the vision stat
         if (effect.GetStatAffected() == Stat.VISION)
             stats[Stat.VISION] = playerClass.GetStat(Stat.VISION);
         break;
     case TurnEffectType.STATMULTIPLIEREFFECT: // Can rese the stat multiplier now
         playerClass.RestoreDefaultStat(effect.GetStatAffected());
         break;
     case TurnEffectType.ITEMEFFECT: // Need to reset affected items
         foreach (Item item in inventory) {
             if (item != null && item.GetType().Equals(effect.GetAffectedItemType())) {
                 /* Reset item cool down and turn settings */
                 item.ResetCoolDown();
                 item.ResetCoolDownSetting();
                 item.ResetUsePerTurn();
                 if (item.RemainingCoolDownTurns() == 0)  // Reduce the cool down of the item to be sure
                     item.ReduceCoolDown();
             }
         }
         break;
     case TurnEffectType.MATERIALEFFECT:
         GetComponent<PhotonView>().RPC("ResetMaterial", PhotonTargets.All, null);
         break;
     case TurnEffectType.MODELCHANGEEFFECT: goto case TurnEffectType.COMPONENTEFFECT;// Need complex detach routine
     case TurnEffectType.COMPONENTEFFECT: // Need complex detaching actions
         effect.ExtraDetachActions();
         break;
     default: break; // Unknown
     }
     effectPanelScript.RemoveTurnEffect(effect);
     turnEffects.Remove(effect);
 }