public int[] GetModForTick(int i) { BitArray protectionArray = new BitArray(GameManager.SPACE_SIZE); ActionMatrix.TryGetValue(ActionType.PROTECTION, out protectionArray); BitArray tempArray = new BitArray(GameManager.SPACE_SIZE); ActionMatrix.TryGetValue(ActionType.TEMPERATURE, out tempArray); BitArray fuelArray = new BitArray(GameManager.SPACE_SIZE); ActionMatrix.TryGetValue(ActionType.CONSUME, out fuelArray); int[] mod = new int[4]; //PROTECTION if (protectionArray[i] == true) { mod[(int)ActionType.PROTECTION] = 2; mod[(int)ActionType.CONSUME] = -1; mod[(int)ActionType.TEMPERATURE] = 2; } else { mod[(int)ActionType.PROTECTION] = 0; mod[(int)ActionType.CONSUME] = 0; mod[(int)ActionType.TEMPERATURE] = 0; } //TEMPERATURE if (tempArray[i] == true) { mod[(int)ActionType.PROTECTION] += -1; mod[(int)ActionType.CONSUME] += -1; mod[(int)ActionType.TEMPERATURE] += -1; } else { mod[(int)ActionType.PROTECTION] += 0; mod[(int)ActionType.CONSUME] += 0; mod[(int)ActionType.TEMPERATURE] += 0; } //FUEL if (fuelArray[i] == true) { mod[(int)ActionType.PROTECTION] += -1; mod[(int)ActionType.CONSUME] += 2; mod[(int)ActionType.TEMPERATURE] += -2; } else { mod[(int)ActionType.PROTECTION] += 0; mod[(int)ActionType.CONSUME] += 0; mod[(int)ActionType.TEMPERATURE] += 0; } return(mod); }
public Result GetResult(string attackerActionKey, string defenderActionKey) { ActionMatrixEntry entry; if (ActionMatrix.TryGetValue(new ActionMatrixEntryKey(attackerActionKey, defenderActionKey), out entry)) { var result = Results.FirstOrDefault(x => x.Key == entry.ResultId); if (result == null) { throw new InvalidRulesException($"Entity '{RenderForLog()}' is missing result '{entry.ResultId}'."); } return(result); } throw new InvalidRulesException($"Entity '{RenderForLog()}' is missing entries in the action matrix. Attacker='{attackerActionKey}', Defender='{defenderActionKey}'"); }
public void CalculateMod() { ModHP = new float[GameManager.SPACE_SIZE]; ModFUEL = new float[GameManager.SPACE_SIZE]; ModTEMP = new float[GameManager.SPACE_SIZE]; BitArray protectionArray = new BitArray(GameManager.SPACE_SIZE); ActionMatrix.TryGetValue(ActionType.PROTECTION, out protectionArray); BitArray tempArray = new BitArray(GameManager.SPACE_SIZE); ActionMatrix.TryGetValue(ActionType.TEMPERATURE, out tempArray); BitArray fuelArray = new BitArray(GameManager.SPACE_SIZE); ActionMatrix.TryGetValue(ActionType.CONSUME, out fuelArray); for (int i = 0; i < GameManager.SPACE_SIZE; i++) { /*//PROTECTION * if(protectionArray[i]==true) * { * ModHP[i] = 2; * ModFUEL[i] = 1; * ModTEMP[i] = 2; * } * else * { * ModHP[i] = 0; * ModFUEL[i] = 0; * ModTEMP[i] = 0; * } * * //TEMPERATURE * if (tempArray[i] == true) * { * ModHP[i] += -2; * ModFUEL[i] += -1; * ModTEMP[i] += +1; * } * else * { * ModHP[i] += 0; * ModFUEL[i] += 0; * ModTEMP[i] += 0; * } * * //FUEL * if (fuelArray[i] == true) * { * ModHP[i] += -1; * ModFUEL[i] += +2; * ModTEMP[i] += -2; * } * else * { * ModHP[i] += 0; * ModFUEL[i] += 0; * ModTEMP[i] += 0; * } */ var mod = this.GetModForTick(i); ModHP[i] = mod[(int)ActionType.PROTECTION]; ModFUEL[i] = mod[(int)ActionType.CONSUME]; ModTEMP[i] = mod[(int)ActionType.TEMPERATURE]; } // Debug.Log("ModHP => " + string.Join(",", ModHP.Select(x => x.ToString()).ToArray())); // Debug.Log("ModFUEL => " + string.Join(",", ModFUEL.Select(x => x.ToString()).ToArray())); // Debug.Log("ModTEMP => " + string.Join(",", ModTEMP.Select(x => x.ToString()).ToArray())); }