private void FindNext() { _realRadius = _searchRadius + UpgradeTree.PlayerArchive.ExtraBulletSpecialLevel * SystemOption.ExBombRadiusPerL * 0.1f * SystemOption.SceneScale; Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, _realRadius, 1 << LayerMask.NameToLayer("Hit")); List <CharacterDistance> cdList = new List <CharacterDistance>(); Debug.Log(enemies.Length); if (enemies.Length > 1) { for (int i = 0; i < enemies.Length; i++) { if (enemies[i].CompareTag("Monster")) { Vector3 deltaPos = enemies[i].gameObject.transform.position - transform.position; CharacterDistance cd = new CharacterDistance(enemies[i].gameObject, deltaPos.magnitude); cdList.Add(cd); } } if (cdList.Count > 1) { cdList.Sort(new DistanceComparer()); _nextTarget = cdList[1].Character.transform.position; //transform.parent = cdList[1].Character.gameObject.transform; cdList[0].Character.gameObject.GetComponent <State>().Hurt(_lazerState.Damage + UpgradeTree.PlayerArchive.ExtraAttackLevel, _lazerState.Shootername, _lazerState.Shooter.Gunname.ToString()); Attenuation(); } else { _nextTarget = cdList[0].Character.transform.position; //transform.parent = cdList[0].Character.gameObject.transform; cdList[0].Character.gameObject.GetComponent <State>().Hurt(_lazerState.Damage + UpgradeTree.PlayerArchive.ExtraAttackLevel, _lazerState.Shootername, _lazerState.Shooter.Gunname.ToString()); } _count++; } else { _lazerState.Destoryself(); } }
private List <string> addDistanceReaction(List <string> fuzzyRules, CharacterDistance distance, string reaction, int frequency) { fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + distance + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(frequency) ); return(fuzzyRules); }
private List <string> addSystematicRules(List <string> fuzzyRules, CharacterDistance preferableDistance, string reaction, int multiplier, int frequencyVariant, bool parabola) { if (frequencyVariant == 0) { return(fuzzyRules); } // predefined values for preferableDistance == CharacterDistance.VeryClose int veryCloseVariant = 0; int closeVariant = 0; int midVariant = 0; int farVariant = 0; int veryFarVariant = 0; int parabolaVariant = parabola? -1: 1; if (preferableDistance == CharacterDistance.VeryClose) { veryCloseVariant = parabola? frequencyVariant : frequencyVariant - 3; closeVariant = frequencyVariant + (1 * multiplier * parabolaVariant); midVariant = frequencyVariant + (2 * multiplier * parabolaVariant); farVariant = frequencyVariant + (3 * multiplier * parabolaVariant); veryFarVariant = frequencyVariant + (5 * multiplier * parabolaVariant); } else if (preferableDistance == CharacterDistance.Close) { veryCloseVariant = frequencyVariant - (1 * multiplier); closeVariant = parabola? frequencyVariant : frequencyVariant - 3; midVariant = frequencyVariant + (1 * multiplier * parabolaVariant); farVariant = frequencyVariant + (2 * multiplier * parabolaVariant); veryFarVariant = frequencyVariant + (3 * multiplier * parabolaVariant); } else if (preferableDistance == CharacterDistance.Mid) { veryCloseVariant = frequencyVariant - (2 * multiplier); closeVariant = frequencyVariant - (1 * multiplier); midVariant = parabola? frequencyVariant : frequencyVariant - 3; farVariant = frequencyVariant + (1 * multiplier * parabolaVariant); veryFarVariant = frequencyVariant + (2 * multiplier * parabolaVariant); } else if (preferableDistance == CharacterDistance.Far) { veryCloseVariant = frequencyVariant - (3 * multiplier); closeVariant = frequencyVariant - (2 * multiplier); midVariant = frequencyVariant - (1 * multiplier); farVariant = parabola? frequencyVariant : frequencyVariant - 3; veryFarVariant = frequencyVariant + (1 * multiplier * parabolaVariant); } else if (preferableDistance == CharacterDistance.VeryFar) { veryCloseVariant = frequencyVariant - (5 * multiplier); closeVariant = frequencyVariant - (3 * multiplier); midVariant = frequencyVariant - (2 * multiplier); farVariant = frequencyVariant - (1 * multiplier); veryFarVariant = parabola? frequencyVariant : frequencyVariant - 3; } //--------------------------------------------------------------------------------------------------------- // Add Conditions: //--------------------------------------------------------------------------------------------------------- //if (parabola || preferableDistance != CharacterDistance.VeryClose){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.VeryClose + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(veryCloseVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.Close){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.Close + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(closeVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.Mid){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.Mid + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(midVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.Far){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.Far + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(farVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.VeryFar){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.VeryFar + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(veryFarVariant) ); //} return(fuzzyRules); }
private List <string> addSystematicRules(List <string> fuzzyRules, CharacterDistance preferableDistance, string reaction, int multiplier, int frequencyVariant) { return(addSystematicRules(fuzzyRules, preferableDistance, reaction, multiplier, frequencyVariant, false)); }
private List<string> addSystematicRules(List<string> fuzzyRules, CharacterDistance preferableDistance, string reaction, int multiplier, int frequencyVariant, bool parabola) { if (frequencyVariant == 0) return fuzzyRules; // predefined values for preferableDistance == CharacterDistance.VeryClose int veryCloseVariant = 0; int closeVariant = 0; int midVariant = 0; int farVariant = 0; int veryFarVariant = 0; int parabolaVariant = parabola? -1: 1; if (preferableDistance == CharacterDistance.VeryClose){ veryCloseVariant = parabola? frequencyVariant : frequencyVariant - 3; closeVariant = frequencyVariant + (1 * multiplier * parabolaVariant); midVariant = frequencyVariant + (2 * multiplier * parabolaVariant); farVariant = frequencyVariant + (3 * multiplier * parabolaVariant); veryFarVariant = frequencyVariant + (5 * multiplier * parabolaVariant); }else if (preferableDistance == CharacterDistance.Close){ veryCloseVariant = frequencyVariant - (1 * multiplier); closeVariant = parabola? frequencyVariant : frequencyVariant - 3; midVariant = frequencyVariant + (1 * multiplier * parabolaVariant); farVariant = frequencyVariant + (2 * multiplier * parabolaVariant); veryFarVariant = frequencyVariant + (3 * multiplier * parabolaVariant); }else if (preferableDistance == CharacterDistance.Mid){ veryCloseVariant = frequencyVariant - (2 * multiplier); closeVariant = frequencyVariant - (1 * multiplier); midVariant = parabola? frequencyVariant : frequencyVariant - 3; farVariant = frequencyVariant + (1 * multiplier * parabolaVariant); veryFarVariant = frequencyVariant + (2 * multiplier * parabolaVariant); }else if (preferableDistance == CharacterDistance.Far){ veryCloseVariant = frequencyVariant - (3 * multiplier); closeVariant = frequencyVariant - (2 * multiplier); midVariant = frequencyVariant - (1 * multiplier); farVariant = parabola? frequencyVariant : frequencyVariant - 3; veryFarVariant = frequencyVariant + (1 * multiplier * parabolaVariant); }else if (preferableDistance == CharacterDistance.VeryFar){ veryCloseVariant = frequencyVariant - (5 * multiplier); closeVariant = frequencyVariant - (3 * multiplier); midVariant = frequencyVariant - (2 * multiplier); farVariant = frequencyVariant - (1 * multiplier); veryFarVariant = parabola? frequencyVariant : frequencyVariant - 3; } //--------------------------------------------------------------------------------------------------------- // Add Conditions: //--------------------------------------------------------------------------------------------------------- //if (parabola || preferableDistance != CharacterDistance.VeryClose){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.VeryClose + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(veryCloseVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.Close){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.Close + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(closeVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.Mid){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.Mid + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(midVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.Far){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.Far + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(farVariant) ); //} //if (parabola || preferableDistance != CharacterDistance.VeryFar){ fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + CharacterDistance.VeryFar + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(veryFarVariant) ); //} return fuzzyRules; }
private List<string> addSystematicRules(List<string> fuzzyRules, CharacterDistance preferableDistance, string reaction, int multiplier, int frequencyVariant) { return addSystematicRules(fuzzyRules, preferableDistance, reaction, multiplier, frequencyVariant, false); }
private List<string> addDistanceReaction(List<string> fuzzyRules, CharacterDistance distance, string reaction, int frequency) { fuzzyRules.Add( AIRule.Rule_IF + AICondition.Distance_Self + AIRule.Rule_IS + distance + AIRule.Rule_THEN + reaction + AIRule.Rule_IS + GetDesirabilityValue(frequency) ); return fuzzyRules; }