private Propulsion GetPropulsion(string name) { GameObject go = GameObject.Find(name); if (go != null) { Propulsion p = go.GetComponentInChildren <Propulsion>(); p.Set_PlayerObj(gameObject); return(p); } else { return(null); } }
public void AddKeyBinding(KeyMappingModel mapping, GameObject module) { if (!string.IsNullOrEmpty(mapping.Key)) { Propulsion p = module.GetComponent <Propulsion>(); if (p != null) { p.Set_PlayerObj(gameObject); } if (key_bindings.ContainsKey(mapping.Key)) { List <KeyMapping> mappings = key_bindings[mapping.Key] as List <KeyMapping>; KeyMapping map = ScriptableObject.CreateInstance <KeyMapping>(); map.Key = mapping.Key; map.value = mapping.value; map.movement_type = mapping.movement_type; map.module = module; Debug.Log("Updating Mapping" + mapping.Key); mappings.Add(map); } else { List <KeyMapping> mappings = new List <KeyMapping>(); KeyMapping map = ScriptableObject.CreateInstance <KeyMapping>(); map.Key = mapping.Key; map.value = mapping.value; map.movement_type = mapping.movement_type; map.module = module; Debug.Log("Adding Mapping" + mapping.Key); mappings.Add(map); key_bindings.Add(mapping.Key, mappings); } } }