public double GetDamage(Boxer defender, AbstractAttack attack, double attackIntensityFactor) {
     double result;
     if (defender.IsCastingAttack) {
         result = attack.FullDamage * COUNTER_ATTACK_DAMAGE_MULTIPLIER;
     }
     else {
         switch (defender.BoxerStance) {
             case Boxer.Stance.NORMAL:
                 result = attack.FullDamage;
                 break;
             case Boxer.Stance.BLOCKING:
                 result = attack.BlockedDamage;
                 break;
             case Boxer.Stance.DODGING:
                 result = attack.IsDodgeable ? 0 : attack.FullDamage;
                 break;
             case Boxer.Stance.STAGGERING:
                 result = attack.FullDamage * STAGGERING_DAMAGE_MULTIPLIER;
                 break;
             default:
                 throw new InvalidOperationException();
         }
     }
     return result * attackIntensityFactor;
 }
 public WinByPointsPrediction(Decision by, Boxer winner, PlayerPrediction playerPrediction)
 {
     By = by;
     Winner = winner;
     Type = "WinByPointsPrediction";
     PlayerPrediction = playerPrediction;
 }
 public RoundKnockOutPrediction(int round, Boxer winner, PlayerPrediction playerPrediction)
 {
     Round = round;
     Winner = winner;
     Type = "RoundKnockOutPrediction";
     PlayerPrediction = playerPrediction;
 }
示例#4
0
 private void SubscribeToBoxerEvents(Boxer boxer) {
     boxer.AttackStarted += boxer_AttackStarted;
     boxer.AttackReceived += boxer_AttackReceived;
     boxer.StanceChanged += boxer_StanceChanged;
     boxer.StaminaRecovered += boxer_StaminaRecovered;
     boxer.ShitHappened += boxer_ShitHappened;
 }
 public void StartAttack(Boxer attacker, AbstractAttack attack) {
     UpdateStaminaSlider(attacker);
     string className = attack.GetType().Name;
     string attackTrigger = String.Format("Attack{0}", className);
     float speedMultiplier = 1000f / attack.CastTimeInMs;
     boxerAnimator.SetFloat(ATTACK_ANIMATION_SPEED, speedMultiplier);
     boxerAnimator.SetTrigger(attackTrigger);
 }
 public void SetBoxer(Boxer value) {
     if (value == null) {
         throw new ArgumentNullException("Boxer is null");
     }
     if (boxer != null) {
         throw new InvalidOperationException("Boxer is already set");
     }
     this.boxer = value;
 }
示例#7
0
        static void Fight(Boxer b1, Boxer b2)
        {
            b1.Block();
            b2.Jeb();

            b2.Uppercut();
            b2.Hook();
            b1.Jeb();
        }
示例#8
0
 private void Start() {
     if (debugMode) {
         this.redStrategy = new TestRedStrategy();
         this.blueStrategy = new TestBlueStrategy();
     }
     else {
         this.redStrategy = GetComponent<ScriptInjector>().RedStrategy;
         this.blueStrategy = GetComponent<ScriptInjector>().BlueStrategy;
     }
     this.redBoxer = new Boxer(redStrategy, Boxer.Color.RED);
     this.blueBoxer = new Boxer(blueStrategy, Boxer.Color.BLUE);
     SubscribeToBoxerEvents(redBoxer);
     SubscribeToBoxerEvents(blueBoxer);
     ResolveFight(redBoxer, blueBoxer);
 }
示例#9
0
        void boxer_AttackReceived(Boxer receiver, BoxerAttackEventArgs eventArgs) {
            BoxerVisualsController boxerController = GetController(receiver);
            Thread boxerThread = GetThread(receiver);
            if (receiver.IsCastingAttack && boxerThread.ThreadState == ThreadState.WaitSleepJoin) {
                boxerThread.Interrupt();
            }
            if (receiver.IsKnockedDown) {
                boxerController.Knockdown(receiver);
                redBoxer.StopFighting();
                blueBoxer.StopFighting();
                Debug.Log(String.Format("Loser is {0}", receiver.BoxerColor));
            }
            else {
                boxerController.AttackReceived(receiver);
            }

        }
 public void SetStance(Boxer.Stance stance) {
     string stanceTrigger;
     switch (stance) {
         case Boxer.Stance.NORMAL:
             stanceTrigger = STANCE_NORMAL;
             break;
         case Boxer.Stance.BLOCKING:
             stanceTrigger = STANCE_BLOCK;
             break;
         case Boxer.Stance.DODGING:
             stanceTrigger = STANCE_DODGE;
             break;
         case Boxer.Stance.STAGGERING:
             stanceTrigger = STANCE_STAGGER;
             break;
         default:
             throw new UnityException("Undefined stance");
     }
     boxerAnimator.SetTrigger(stanceTrigger);
 }
示例#11
0
 public void ChangeStance(Boxer.Stance newStance) {
     if (boxer.BoxerStance != newStance) {
         ResolveAccumulatedStun();
         boxer.ChangeStance(newStance);
     }
 }
示例#12
0
 void boxer_AttackStarted(Boxer attacker, BoxerAttackEventArgs eventArgs) {
     BoxerVisualsController boxerController = GetController(attacker);
     boxerController.StartAttack(attacker, eventArgs.Attack);
 }
示例#13
0
 void boxer_ShitHappened(Boxer sender, DebugMessageEventArgs eventArgs) {
     Debug.LogWarning(String.Format("Shit happened in thread {0}, method {1} with message: {2}", eventArgs.ThreadName, eventArgs.MethodName, eventArgs.Message));
 }
示例#14
0
    /*
     * HP you can buy to increase chances of not falling
     * Breathing can buy to increase the amount of HP you recover when enemy is KO
     * Recovery can buy to increase the amount of HP you recover when you fall
     * Strength to do heavier hits
     * Stamina to be able to get up easier
     */

    // Start is called before the first frame update
    void Start()
    {
        next = GameObject.Find("All Boxers").GetComponentsInChildren <AnimHandler>();

        fadeScreen.color = Color.clear;

        shopItem[0] = new ShopItem("Add Energy", "Will give you more energy for the next fight.", 5);
        shopItem[1] = new ShopItem("Increase Energy", "This will increase your max energy.", 15);
        shopItem[2] = new ShopItem("Improve Breathing", "When you KO a foe, you will get more hp back with better breathing.", 25);
        shopItem[3] = new ShopItem("Better Recovery", "Will give you back more energy after getting up from being KOed.", 30);
        shopItem[4] = new ShopItem("More Strength", "You will pack a more powerful punch.", 50);
        shopItem[5] = new ShopItem("Longer Stamina", "This will make your getting up game better.", 70);

        //
        for (int i = 0; i < shopImg.Length; i++)
        {
            shopImg[i].GetComponentsInChildren <TextMeshProUGUI>()[0].text = $"{shopItem[i].item}\n\n${shopItem[i].cost}";
        }

        //
        for (int i = 0; i < 2; i++)
        {
            boxer[i] = new Boxer();
            anim[i]  = boxerObj[i].GetComponent <Animator>();

            Texture2D tt = new Texture2D(16, 1);

            tt = GetNewBoxerTexture();

            //
            foreach (SkinnedMeshRenderer smr in boxerObj[i].GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                smr.material.mainTexture = tt;
            }

            pow[i].SetActive(false);
        }

        boxer[1].RandInit(2);

        //
        foreach (SkinnedMeshRenderer smr in boxerObj[0].GetComponentsInChildren <SkinnedMeshRenderer>())
        {
            smr.material.mainTexture = MenuCTRL.main;
        }

        //
        for (int i = 0; i < next.Length; i++)
        {
            Texture2D tt = new Texture2D(16, 1);

            tt = GetNewBoxerTexture();

            //
            foreach (SkinnedMeshRenderer smr in next[i].GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                smr.material.mainTexture = tt;
                smr.transform.parent.GetComponent <Animator>().SetTrigger("Idle");
            }
        }

        PostProcessVolume volume = Camera.main.GetComponent <PostProcessVolume>();

        volume.profile.TryGetSettings(out cA);

        StartCoroutine(AI());
    }
示例#15
0
 private BoxerVisualsController GetController(Boxer boxer) {
     switch (boxer.BoxerColor) {
         case Boxer.Color.RED:
             return redBoxerVisualsController;
         case Boxer.Color.BLUE:
             return blueBoxerVisualsController;
         default:
             throw new UnityException("Invalid state");
     }
 }
示例#16
0
 void boxer_StanceChanged(Boxer sender, EventArgs eventArgs) {
     BoxerVisualsController boxerController = GetController(sender);
     boxerController.SetStance(sender.BoxerStance);
 }
示例#17
0
 public int GetStunDuration(Boxer boxer, AbstractAttack attack, double attackIntensityFactor) {
     return attack.StunDurationInMs;
 }
 public void Knockdown(Boxer receiver) {
     boxerAnimator.SetTrigger(KNOCKDOWN);
     UpdateHpSlider(receiver);
 }
 public void AttackReceived(Boxer receiver) {
     boxerAnimator.SetTrigger(RECEIVED_ATTACK);
     UpdateHpSlider(receiver);
 }
 /// <summary>
 /// this is the constructor of MakeGroup
 /// </summary>
 /// <param name="components">the selected shapes/boxes </param>
 /// <param name="parentBox">the parent box</param>
 public MakeGroup(List <GodShape> components, Boxer parentBox)
 {
     _components = components;
     _parentBox  = parentBox;
     _newBox     = new Boxer();
 }
示例#21
0
 /// <summary>
 /// Constructor of SaveFile
 /// </summary>
 /// <param name="box">the box where all objects are located in </param>
 public SaveFile(Boxer box)
 {
     _boxer = box;
 }
 public PlayerAttackStrategy(Boxer player, Opponent opponent, Action notifyGameEnded, Stack <Action> work)
     : base(opponent, work, notifyGameEnded) => _player = player;
示例#23
0
    void Start()
    {
        worldData = new DataPool();

        WorldBuilderProtocol.createWorld(ref worldData, 220, 220);

        List <Boxer> boxers = WorldBuilderProtocol.generateBoxerRecruits(ref worldData, 0, 500);

        foreach (Boxer b in boxers)
        {
            b.logBoxerStats();
        }

        Debug.Log("-----------");
        Boxer boxer = boxers [Random.Range(0, boxers.Count)];

        Debug.Log("Introducing ");

        worldData.Boxers.Add(boxer);

        Exercise accuracyTraining  = new Exercise("Double End Bag", worldData.getExerciseDescription("Double End Bag"), true);
        Exercise enduranceTraining = new Exercise("Punch Glove", worldData.getExerciseDescription("Punch Glove"), true);
        Exercise speedTraining     = new Exercise("Sprints", worldData.getExerciseDescription("Sprints"), true);
        Exercise strengthTraining  = new Exercise("Punching Bag", worldData.getExerciseDescription("Punching Bag"), true);
        Exercise healthTraining    = new Exercise("Laps", worldData.getExerciseDescription("Laps"), true);

        List <int> accuracyTrainingFactors  = worldData.getExerciseProgressAcculumative(accuracyTraining.Name, 2);
        List <int> enduranceTrainingFactors = worldData.getExerciseProgressAcculumative(enduranceTraining.Name, 2);
        List <int> speedTrainingFactors     = worldData.getExerciseProgressAcculumative(speedTraining.Name, 2);
        List <int> strengthTrainingFactors  = worldData.getExerciseProgressAcculumative(strengthTraining.Name, 2);
        List <int> healthTrainingFactors    = worldData.getExerciseProgressAcculumative(healthTraining.Name, 3);

        accuracyTraining.setFactors(
            accuracyTrainingFactors [0], accuracyTrainingFactors [1], accuracyTrainingFactors [2],
            accuracyTrainingFactors [3], accuracyTrainingFactors [4], 20);
        enduranceTraining.setFactors(
            enduranceTrainingFactors [0], enduranceTrainingFactors [1], enduranceTrainingFactors [2],
            enduranceTrainingFactors [3], enduranceTrainingFactors [4], 20);
        speedTraining.setFactors(
            speedTrainingFactors [0], speedTrainingFactors [1], speedTrainingFactors [2],
            speedTrainingFactors [3], speedTrainingFactors [4], 20);
        strengthTraining.setFactors(
            strengthTrainingFactors [0], strengthTrainingFactors [1], strengthTrainingFactors [2],
            strengthTrainingFactors [3], strengthTrainingFactors [4], 20);
        healthTraining.setFactors(
            healthTrainingFactors [0], healthTrainingFactors [1], healthTrainingFactors [2],
            healthTrainingFactors [3], healthTrainingFactors [4], 20);

        accurracyTrainingFacility = new Facility();
        accurracyTrainingFacility.createExerciseFacility(2, accuracyTraining);

        enduranceTrainingFacility = new Facility();
        enduranceTrainingFacility.createExerciseFacility(2, enduranceTraining);

        healthTrainingFacility = new Facility();
        healthTrainingFacility.createExerciseFacility(3, healthTraining);

        speedTrainingFacility = new Facility();
        speedTrainingFacility.createExerciseFacility(2, speedTraining);

        strengthTrainingFacility = new Facility();
        strengthTrainingFacility.createExerciseFacility(2, strengthTraining);

        //trainStrength ();
        trainEverything();
    }
示例#24
0
 public AttackStrategy(Boxer other, Stack <Action> work, Action notifyGameEnded)
 {
     Other            = other;
     Work             = work;
     _notifyGameEnded = notifyGameEnded;
 }
示例#25
0
 public double GetAttackIntensityFactor(Boxer boxer) {
     return Math.Max(MINIMAL_ATTACK_INTENSITY_FACTOR, (double)boxer.Stamina / Boxer.MAX_STAMINA);
 }
 public void UpdateHpSlider(Boxer boxer) {
     hpSlider.value = (float)boxer.HitPoints;
 }
 public OpponentAttackStrategy(Opponent opponent, Boxer player, Action notifyGameEnded, Stack <Action> work) : base(player, work, notifyGameEnded)
 {
     _opponent = opponent;
 }
 public void UpdateStaminaSlider(Boxer boxer) {
     staminaSlider.value = boxer.Stamina;
 }
示例#29
0
 private Thread GetThread(Boxer boxer) {
     switch (boxer.BoxerColor) {
         case Boxer.Color.RED:
             return redBoxerThread;
         case Boxer.Color.BLUE:
             return blueBoxerThread;
         default:
             throw new UnityException("Invalid state");
     }
 }
示例#30
0
 public BoxerWorker(Boxer player, Boxer opponent) {
     this.Player = player;
     this.Opponent = opponent;
 }
示例#31
0
        private void ResolveFight(Boxer redBoxer, Boxer blueBoxer) {
            BoxerWorker redBoxerWorker = new BoxerWorker(redBoxer, blueBoxer);
            BoxerWorker blueBoxerWorker = new BoxerWorker(blueBoxer, redBoxer);

            this.redBoxerThread = new Thread(redBoxerWorker.DoWork);
            this.blueBoxerThread = new Thread(blueBoxerWorker.DoWork);

            //start the fight in 5 seconds
            DateTime startTime;
            startTime = DateTime.Now.AddSeconds(5);
            redBoxerThread.Start(startTime);
            blueBoxerThread.Start(startTime);
        }
示例#32
0
 public virtual void WinByPoints(Boxer boxer, Decision desisionType)
 {
     var winPrediction = CreateWinnerPrediction(boxer);
     var byPointsPredictions = new WinByPointsPrediction(desisionType, boxer, this);
     AddPredictions(winPrediction, byPointsPredictions);
 }
示例#33
0
 private WinnerPrediction CreateWinnerPrediction(Boxer boxer)
 {
     return new WinnerPrediction(boxer, this);
 }
示例#34
0
 private void Start()
 {
     playerBoxer = gameObject.GetComponentInParent <Boxer>();
 }
示例#35
0
 void boxer_StaminaRecovered(Boxer sender, EventArgs eventArgs) {
     BoxerVisualsController boxerController = GetController(sender);
     boxerController.UpdateStaminaSlider(sender);
 }
示例#36
0
 public WinnerPrediction(Boxer winner, PlayerPrediction playerPrediction)
 {
     Winner = winner;
     Type = "WinnerPrediction";
     PlayerPrediction = playerPrediction;
 }
 public BoxerStanceChangedEventArgs(Boxer.Stance newStance) {
     this.NewStance = newStance;
 }
示例#38
0
 public BoxerApi(Boxer boxer) {
     this.boxer = boxer;
 }
示例#39
0
		public void RemoveDelegateTypeMismatch ()
		{
			Delegate boxer = new Boxer (() => new object ());
			Delegate.Remove (boxer, new WrongDelegate (() => 42));
		}
示例#40
0
        public ActionResult Create(Boxer boxer)
        {
            _boxerService.Create(boxer);

            return(RedirectToAction("Create"));
        }