I have an issue I’m trying to figure out what structure code is this found it in javascript and trying to convert it to C# I made it work by replacing {} to () and made it work as an object See second example.
The main issue is how can I use it in such way that will take enum to get correct value
Example:
public enum Type { None, Normal, Fighting, Fire, Water, Grass, }
player.type1 is a value from enum “Fire”.
rival.type1 is a value from enum “Grass”.
I would like to use it as Debug.Log(“The value is:” Effectiveness + player.Type + rival.Type)
In result i would like to get value 2.
Javascript Objective-oriented Programming with out class example below
var Effectiveness= { Fire: { Normal: 1, Fire: 0.5, Water: 0.5, Grass: 2 }, Water: { Normal: 1, Fire: 2, Water: 0.5, Grass: 0.5 } };
Unity C# work around it it work fine but first time using it see example below
var Effectiveness= ( Fire: ( Normal: 1, Fire: 0.5, Water: 0.5, Grass: 2 ), Water: ( Normal: 1, Fire: 2, Water: 0.5, Grass: 0.5 ) ); Debug.Log(Effectiveness.Fire.Grass); // Will spit out result as 2