public static Controlled <double, ArgumentException> FindSide(char side, double perimeter, double a = 0, double b = 0, double c = 0) { var ctrl = new Controlled <double, ArgumentException>(); switch (side) { case 'a': ctrl.ReturnValue = perimeter - b - c; break; case 'b': ctrl.ReturnValue = perimeter - a - c; break; case 'c': ctrl.ReturnValue = perimeter - a - b; break; default: ctrl.Exception = new ArgumentException("Invalid character"); break; } return(ctrl); }
protected void ControlEnemy(int indexOfEnemy, float atk, GameObject hitEffect, string type, float time, float height = 2.0f) { if (indexOfEnemy > targets.Count) { return; } LookAtTarget(targets[indexOfEnemy].transform); BaseData data = targets[indexOfEnemy].GetComponent <BaseData>(); Controlled ctrled = targets[indexOfEnemy].GetComponent <Controlled>(); if (data != null) { // add a "get hit" effect to this enemy DoHitEffect(indexOfEnemy, hitEffect); m_hasAtked = true; // may be the character only control enemy but not attack it if (atk > 0) { data.Damaged(atk, PlayerData.GetInstance().armPieRate); if (ctrled != null) { if (ctrled.controller == null) { ctrled.controller = gameObject; } StartCoroutine(ctrled.controlFuncDic[type](time, height)); } if (data.curLife <= 0) { DoDefeatEnemyByPhyatk(indexOfEnemy, data.valueExp, data.valueGold); } } } }
public void OnTriggerEnter(Collider collider) { if (controlType.Equals("")) { Debug.LogError("NUll Control type"); } if (collider.tag.Equals(targetTag)) { if (targetTag.Equals("Player")) { PlayerData.GetInstance().Damaged(atk); } else { Damage(collider.transform); } Controlled ctrl = collider.GetComponent <Controlled>(); if (ctrl == null) { Debug.LogError("Controlled is not found"); } if (ctrl.controller == null) { ctrl.controller = PlayerData.GetInstance().action.gameObject; } StartCoroutine(ctrl.controlFuncDic[controlType](time, d)); } }
public static Controlled <double, ArgumentException> GreatestCommonDivider(params double[] numbers) { var ctrl = new Controlled <double, ArgumentException>(); if (numbers == null) { ctrl.Exception = new ArgumentNullException(); } else if (numbers.Length == 1) { ctrl.ReturnValue = numbers[0]; return(ctrl); } else if (numbers.Length == 2) { ctrl.ReturnValue = GreatestCommonDivider(numbers[0], numbers[1]); return(ctrl); } else { for (int i = 1; i < numbers.Length; i++) { numbers[i] = GreatestCommonDivider(Math.Round(numbers[i - 1], 0), Math.Round(numbers[i], 0)); } } ctrl.ReturnValue = numbers[numbers.Length - 1]; return(ctrl); }
public void Apply_NotACharacter_Test() { var entity = Mock.Of <IEntity>(); var controlled = new Controlled(); controlled.Apply(entity); Assert.IsTrue(true); // If we made it here without exception then the test passed }
protected void GetControlled(Transform tf) { m_ctrl = tf.GetComponent <Controlled>(); if (m_ctrl == null) { Debug.LogError("Controlled is not found!!"); } }
public void Apply_Character_WithExistingControlledCondition_Test() { var character = CreateMockCharacter(); character.Conditions.Add(new Controlled()); var controlled = new Controlled(); controlled.Apply(character); }
public void Apply_Character_NoConditions_Test() { var character = CreateMockCharacter(); var controlled = new Controlled(); controlled.Apply(character); Assert.AreEqual(EntityIds.CONTROLLED_CONDITION_ID, character.Conditions[0].Id); Assert.AreSame(controlled, character.Conditions[0]); }
public void Remove_NoConditions_Test() { var character = CreateMockCharacter(); var controlled = new Controlled(); controlled.Apply(character); controlled.Remove(character); Assert.AreEqual(0, character.Conditions.Count); }
public IList <Readable_LifeTarget> GetValue(Controlled caller, Game game, IList <Readable_LifeTarget> outputType) { List <Readable_LifeTarget> targets = new List <Readable_LifeTarget>(); foreach (Readable_MonsterCard monster in game.Get_MonstersInPlay()) { targets.Add(monster); } return(targets); }
// Use this for initialization void Start( ) { dmg = GetComponentInParent <NashorData>().atk; m_player = PlayerData.GetInstance().action.gameObject; m_playCtrled = PlayerData.GetInstance().action.GetComponent <Controlled>(); if (m_playCtrled == null) { Debug.LogError("Controlled has not be found at player!!"); } }
// Use this for initialization void Start( ) { dmg = GetComponentInParent<NashorData>().atk; m_player = PlayerData.GetInstance().action.gameObject; m_playCtrled = PlayerData.GetInstance().action.GetComponent<Controlled>(); if (m_playCtrled == null) { Debug.LogError("Controlled has not be found at player!!"); } }
public IList <Readable_LifeTarget> GetValue(Controlled controlled, Game game, IList <Readable_LifeTarget> outputType) { IEnumerable <Readable_GamePlayer> players = this.GetValue(controlled, game, (IList <Readable_GamePlayer>)null); List <Readable_LifeTarget> targets = new List <Readable_LifeTarget>(); foreach (Readable_GamePlayer player in players) { targets.Add(player); } return(targets); }
public IList <Readable_LifeTarget> GetValue(Controlled caller, Game game, IList <Readable_LifeTarget> outputType) { IEnumerable <Readable_MonsterCard> monsters = new AllMonsters_Provider().GetValue(caller, game, (IList <Readable_MonsterCard>)null); List <Readable_LifeTarget> enemyMonsters = new List <Readable_LifeTarget>(); foreach (Readable_MonsterCard monster in monsters) { if (!monster.Get_ControllerID().Equals(caller.Get_ControllerID())) { enemyMonsters.Add(monster); } } return(enemyMonsters); }
public IList <Readable_GamePlayer> GetValue(Controlled controlled, Game game, IList <Readable_GamePlayer> outputType) { IEnumerable <Readable_GamePlayer> players = game.Players; List <Readable_GamePlayer> opponents = new List <Readable_GamePlayer>(); foreach (Readable_GamePlayer player in players) { if (!player.GetID((Readable_GamePlayer)null).Equals(controlled.Get_ControllerID())) { opponents.Add(player); } } return(opponents); }
// Use this for initialization void Start( ) { if (Camera.main == null) { Debug.LogError("Error: no main camera found"); } else { m_Cam = Camera.main.transform; } m_action = GetComponent<CharacterAction>(); m_agent = GetComponent<NavMeshAgent>(); m_animator = GetComponent<Animator>(); m_ctrled = GetComponent<Controlled>(); }
// Use this for initialization void Start( ) { if (Camera.main == null) { Debug.LogError("Error: no main camera found"); } else { m_Cam = Camera.main.transform; } m_action = GetComponent <CharacterAction>(); m_agent = GetComponent <NavMeshAgent>(); m_animator = GetComponent <Animator>(); m_ctrled = GetComponent <Controlled>(); }
// Use this for initialization void Start( ) { m_skillManager = GetComponent <SkillManager>(); m_animator = GetComponent <Animator>(); m_agent = GetComponent <NavMeshAgent>(); m_ctrled = GetComponent <Controlled>(); m_baseMoveSpeed = m_agent.speed; if (isMelee) { m_meleeWeaponTrail = GetComponentInChildren <MeleeWeaponTrail>(); } PlayerData.GetInstance().action = this; }
public override void OnTriggerEnter(Collider collider) { // damage all enemy it if (collider.tag.Equals("Enemy")) { // a magic has a 100% hit rate Damage(collider.gameObject.transform, 1); // knock back Controlled contrlled = collider.gameObject.GetComponent <Controlled>(); if (contrlled != null) { if (contrlled.controller == null) { contrlled.controller = PlayerData.GetInstance().action.gameObject; } StartCoroutine(contrlled.KnockedBack(0.3f, 2)); } } }
public static Controlled <string, ArgumentException> Sequence(double[] top, double[] bot, double[] sum) // It only works with a1 elements for now. Ex. (a3+a6=8 | a2-a7=16) { var ctrl = new Controlled <string, ArgumentException>(); if (sum.Length != 2) // Checks of the sum array has only 2 elements { ctrl.Exception = new ArgumentException("The sum can have only 2 elements"); } double denD = 0, numD = 0; double numA = 0, denA = 0; double a, d; CalculateSequence(top, bot, sum, ref numA, ref denA, ref numD, ref denD); if (numA % denA == 0 && numD % denD == 0) // Checks if you can devide the numbers and if you can it devides them and ctrl.ReturnValue =s the answer. { a = numA / denA; d = numD / denD; ctrl.ReturnValue = $"a = {a} d = {d}"; } else if (numA % denA == 0 && numD % denD != 0) { a = numA / denA; Fractions.Shorten(ref numD, ref denD); ctrl.ReturnValue = $"a = {a} + d = {numD}/{denD}"; } else if (numA % denA != 0 && numD % denD == 0) { d = numD / denD; Fractions.Shorten(ref numA, ref denA); ctrl.ReturnValue = $"a = {numA}/{denA} d = {d}"; } else { Fractions.Shorten(ref numD, ref denD); Fractions.Shorten(ref numA, ref denA); ctrl.ReturnValue = $"a = {numA}/{denA } d = {numD}/{denD}"; } return(ctrl); }
void ChangeControl(Controlled controlled) { switch (controlled) { case Controlled.None: Debug.Log("None in control"); character.allowMovement = false; airplane.input.isActive = false; break; case Controlled.Alfonso: airplane.input.isActive = false; character.allowMovement = true; break; case Controlled.Plane: character.allowMovement = false; airplane.input.isActive = true; break; } }
public static Controlled <double, ArgumentException> CalculateFraction(double[] numerator, int[] denominator, ref double num, ref double den, char symbol = '+') { var ctrl = new Controlled <double, ArgumentException>(); double result = 0; double commonDenominator = 1; if (numerator.Length > denominator.Length || numerator.Length < denominator.Length) { ctrl.Exception = new ArgumentException("Not enough numerators or denominators"); } if (symbol == '+' || symbol == '-') { for (int i = 0; i < denominator.Length; i++) { commonDenominator = LeastCommonMultiple(commonDenominator, denominator[i]); } for (int i = 0; i < numerator.Length; i++) { double temp = (commonDenominator / denominator[i]) * numerator[i]; _ = symbol == '+' ? result += temp : result = temp - result; if (symbol == '-') { result *= -1; } } } else if (symbol == '*' || symbol == '/') { commonDenominator = denominator[0]; if (symbol == '/') { for (int i = 0; i < numerator.Length - 1; i++) { double tempNum = numerator[i] * denominator[i + 1]; result += tempNum; commonDenominator *= numerator[i + 1]; } } if (symbol == '*') { for (int i = 0; i < numerator.Length - 1; i++) { double tempNum = (numerator[i] * numerator[i + 1]); result += tempNum; commonDenominator *= denominator[i + 1]; } } } else { ctrl.Exception = new ArgumentException("Not a valid symbol set"); } num = result; den = commonDenominator; ctrl.ReturnValue = result / commonDenominator; return(ctrl); }
protected void GetControlled(Transform tf) { m_ctrl = tf.GetComponent<Controlled>(); if (m_ctrl == null) Debug.LogError("Controlled is not found!!"); }
public IList <Readable_MonsterCard> GetValue(Controlled caller, Game game, IList <Readable_MonsterCard> outputType) { return(game.Get_MonstersInPlay()); }
public IList <Readable_LifeTarget> GetValue(Controlled caller, Game game, IList <Readable_LifeTarget> outputType) { return(game.Get_LifeTargets()); }
public override void Calc(GameState g, ICollection <IGameObj> nearbyObjects) { Face(g.Player.Loc); Controlled.Thrust(); Controlled.Fire(g); }
public override void Calc(GameState g, ICollection <IGameObj> nearbyObjects) { //Face(Target.Loc); Controlled.Thrust(); }
// Use this for initialization void Start( ) { m_skillManager = GetComponent<SkillManager>(); m_animator = GetComponent<Animator>(); m_agent = GetComponent<NavMeshAgent>(); m_ctrled = GetComponent<Controlled>(); m_baseMoveSpeed = m_agent.speed; if (isMelee) { m_meleeWeaponTrail = GetComponentInChildren<MeleeWeaponTrail>(); } PlayerData.GetInstance().action = this; }