Esempio n. 1
0
 public static void PlaySFX(AIMCritInfo info)
 {
     try {
         GameRepresentation GameRep = info.target.GameRep;
         if (GameRep == null)
         {
             return;
         }
         if (info.weapon.weaponRep != null && info.weapon.weaponRep.HasWeaponEffect)
         {
             WwiseManager.SetSwitch(info.weapon.weaponRep.WeaponEffect.weaponImpactType, GameRep.audioObject);
         }
         else if (laser_medium != 0)
         {
             WwiseManager.SetSwitch(laser_medium, GameRep.audioObject);
         }
         if (mech_critical_hit != 0)
         {
             WwiseManager.SetSwitch(mech_critical_hit, GameRep.audioObject);
         }
         if (impact_weapon != 0)
         {
             WwiseManager.PostEvent(impact_weapon, GameRep.audioObject, null, null);
         }
         if (explosion_small != 0)
         {
             WwiseManager.PostEvent(explosion_small, GameRep.audioObject, null, null);
         }
     }                 catch (Exception ex) { Error(ex); }
 }
Esempio n. 2
0
        public void OnGet()
        {
            GameId = Guid.NewGuid();
            var gameManager = GameStorage.GetOrCreateGame(GameId);

            GameRepresentation = gameManager.GetActualGameState();
        }
Esempio n. 3
0
        public void testSerializationAndDeserialization()
        {
            // set up board
            Board board = new Board(5, 5, 4);

            for (int i = 0; i < 4; i++)
            {
                board.SetBombState(i, 0, 0, true);
            }

            board.SetBombState(0, 0, 0, false);
            board.SetBombState(2, 2, 2, false);
            board[0, 1, 2].Highlighted = true;

            // serialize Board
            string json = GameSerializer.serialize(new GameRepresentation(board, new PlayerStats()));

            // deserialize again and check if the values are still the same
            GameRepresentation grep = GameSerializer.deserialize(json);

            Assert.AreEqual(grep.board[0, 1, 2].PosX, 0);
            Assert.AreEqual(grep.board[0, 1, 2].PosY, 1);
            Assert.AreEqual(grep.board[0, 1, 2].PosZ, 2);//
            Assert.AreEqual(grep.board[0, 0, 0].IsBomb, false, "huh...");
            Assert.AreEqual(grep.board[1, 0, 0].IsBomb, true, "hmm...");
            Assert.AreEqual(grep.board[2, 2, 2].IsBomb, false, "heh.");
            Assert.AreEqual(grep.board[0, 1, 2].Highlighted, true, "huh...");
        }
Esempio n. 4
0
 public ActionResult <GameRepresentation> Put(string id, [FromBody] GameRepresentation gameRepresentation)
 {
     if (id != gameRepresentation.Id)
     {
         return(BadRequest());
     }
     try
     {
         var game = new Game
         {
             Id          = ObjectId.Parse(gameRepresentation.Id),
             Name        = gameRepresentation.Name,
             Description = gameRepresentation.Description,
             Rating      = gameRepresentation.Rating,
             Released    = DateTimeOffset.Parse(gameRepresentation.Released)
         };
         var result = _service.Update(game);
         if (result == false)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
        static void Postfix(GameRepresentation __instance, CombatGameState combat, Team team)
        {
            if (__instance != null && __instance.parentCombatant != null && ModState.AmbushBuildingGUIDToTurrets.Keys.Contains(__instance.parentCombatant.GUID))
            {
                Mod.Log.Debug?.Write($"Building {CombatantUtils.Label(__instance.parentCombatant)} contains a trap, marking it as hostile.");

                Traverse          edgeHighlightT = Traverse.Create(__instance).Property("edgeHighlight");
                MechEdgeSelection edgeHighlight  = edgeHighlightT.GetValue <MechEdgeSelection>();
                edgeHighlight.SetTeam(3);
            }
        }
        private IEnumerator GameRequest(UnityWebRequest request, string httpVerb, Action <Game> responseHandler, Action <List <Game> > multipleResponseHandler)
        {
            yield return(MakeRequest(request, httpVerb, response =>
            {
                if (responseHandler != null)
                {
                    GameRepresentation result = JsonUtility.FromJson <GameRepresentation>(request.downloadHandler.text);
                    responseHandler(result.ToGame());
                }

                if (multipleResponseHandler != null)
                {
                    List <GameRepresentation> results = new List <GameRepresentation>(JsonHelper.getJsonArray <GameRepresentation>(request.downloadHandler.text));
                    multipleResponseHandler(results.ConvertAll(game => game.ToGame()));
                }
            }));
        }
Esempio n. 7
0
        public static ParticleSystem PlayVFXAt(GameRepresentation gameRep, Transform parentTransform, Vector3 offset, string vfxName, string effectName,
                                               bool attached, Vector3 lookAtPos, bool oneShot, float duration)
        {
            if (string.IsNullOrEmpty(vfxName))
            {
                return(null);
            }

            GameObject gameObject = gameRep.parentCombatant.Combat.DataManager.PooledInstantiate(vfxName, BattleTechResourceType.Prefab, null, null, null);

            if (gameObject == null)
            {
                GameRepresentation.initLogger.LogError("Error instantiating VFX " + vfxName, gameRep);
                return(null);
            }
            ParticleSystem component = gameObject.GetComponent <ParticleSystem>();

            component.Stop(true);
            component.Clear(true);
            Transform transform = gameObject.transform;

            transform.SetParent(null);

            BTWindZone componentInChildren = gameObject.GetComponentInChildren <BTWindZone>(true);

            if (componentInChildren != null && componentInChildren.enabled)
            {
                componentInChildren.ResetZero();
            }

            BTLightAnimator componentInChildren2 = gameObject.GetComponentInChildren <BTLightAnimator>(true);

            if (attached)
            {
                transform.SetParent(parentTransform, false);
                transform.localPosition = offset;
            }
            else
            {
                transform.localPosition = Vector3.zero;
                if (parentTransform != null)
                {
                    transform.position = parentTransform.position;
                }
                transform.position += offset;
            }

            if (lookAtPos != Vector3.zero)
            {
                transform.LookAt(lookAtPos);
            }
            else
            {
                transform.localRotation = Quaternion.identity;
            }
            transform.localScale = Vector3.one;

            if (oneShot)
            {
                AutoPoolObject autoPoolObject = gameObject.GetComponent <AutoPoolObject>();
                if (autoPoolObject == null)
                {
                    autoPoolObject = gameObject.AddComponent <AutoPoolObject>();
                }
                if (duration > 0f)
                {
                    autoPoolObject.Init(gameRep.parentCombatant.Combat.DataManager, vfxName, duration);
                }
                else
                {
                    autoPoolObject.Init(gameRep.parentCombatant.Combat.DataManager, vfxName, component);
                }
            }
            else
            {
                List <ParticleSystem> list = null;
                if (gameRep.persistentVFXParticles.TryGetValue(effectName, out list))
                {
                    list.Add(component);
                    gameRep.persistentVFXParticles[effectName] = list;
                }
                else
                {
                    list = new List <ParticleSystem>();
                    list.Add(component);
                    gameRep.persistentVFXParticles[effectName] = list;
                }
            }

            BTCustomRenderer.SetVFXMultiplier(component);
            component.Play(true);
            if (componentInChildren != null)
            {
                componentInChildren.PlayAnimCurve();
            }
            if (componentInChildren2 != null)
            {
                componentInChildren2.PlayAnimation();
            }

            return(component);
        }