private void AddCollisionBox(string name, Transform parent, CollisionBoxData properties) { GameObject collision_box = null; foreach (GameObject g in CollisionBoxPool) { if (!g.GetComponent <CollisionBox>().isInUse) { collision_box = g; break; } } collision_box.GetComponent <CollisionBox>().Activate(name, parent, parent_player, properties, facing, DrawDebugBoxes); collision_box.GetComponent <CollisionBox>().DrawDebugBoxes(); UsedCollisionBoxes.Add(collision_box); //GameObject collision_box = Xeo.Utility.CreateChildObj(name, parent); //collision_box.name = name; //collision_box.layer = LayerMask.NameToLayer(properties.type.ToString()); //collision_box.transform.parent = parent; //collision_box.transform.localPosition = Vector3.zero; //collision_box.transform.position += new Vector3( // properties._dimensions.position.x * facing, // properties._dimensions.position.y); //BoxCollider2D _collider = collision_box.GetComponent<BoxCollider2D>(); //_collider.isTrigger = properties.isTrigger; //_collider.size = properties._dimensions.size; }
public static CollisionBoxData ConvertToData(CollisionBox collisionBox) { CollisionBoxData data = new CollisionBoxData(); data.height = collisionBox.rectangle.Height; data.width = collisionBox.rectangle.Width; data.offset = collisionBox.offset; return data; }
/*******************************************************************************************************/ /// <summary> /// Utility method to set data for this collision group manager based on the active frame /// </summary> /// <param name="collisionBox_data"></param> /// <param name="launch_direction"></param> public void SetData(BaseCharacter owner, CollisionBoxData collisionBox_data, float launch_direction) { this.owner = owner; this.properties = collisionBox_data; gameObject.layer = LayerMask.NameToLayer(collisionBox_data.type.ToString()); this.attack_damage = collisionBox_data.attack_damage; this.knockback_growth = collisionBox_data.knockback_growth; this.base_knockback = collisionBox_data.base_knockback; this.launch_angle = collisionBox_data.launch_angle; this.launch_direction = launch_direction; }
public HurtState(FSM parent, CollisionBoxData properties, float launch_direction) { eventManager = new EventManager(); this.sm = parent; this.attack_damage = properties.attack_damage; this.knockback_growth = properties.knockback_growth; this.victim_percent = (1f - parent._character._stamina.GetPercentage()) * 100f; this.base_knockback = properties.base_knockback; this.launch_angle = properties.launch_angle; this.launch_direction = launch_direction; OnStateEnter(); }
public void Activate(string name, Transform parent, BaseCharacter owner, CollisionBoxData properties, float facing, bool drawDebug = true) { isInUse = true; isDebug = drawDebug; gameObject.name = name; gameObject.layer = LayerMask.NameToLayer(properties.type.ToString()); transform.parent = parent; transform.localPosition = Vector3.zero; transform.position += new Vector3( properties._dimensions.position.x * facing, properties._dimensions.position.y); transform.localScale = new Vector3( properties._dimensions.size.x, properties._dimensions.size.y); _collider.enabled = true; _collider.isTrigger = properties.isTrigger; this.owner = owner; boxType = properties.type; }
public HitEvent(BaseCharacter player_hit, CollisionBoxData properties, float launch_direction) { this.player_hit = player_hit; this.properties = properties; this.launch_dir = launch_direction; }
public static CollisionBox CreateFromData(CollisionBoxData data) { CollisionBox collisionBox = new CollisionBox(data.height, data.width, data.offset); return collisionBox; }