/// <summary> /// /// </summary> /// <param name="collision"></param> private void OnCollisionEnter2D(Collision2D collision) { // Check if hit any game element GameElement element = collision.collider.GetComponent <GameElement>(); if (element != null) { element.HitByPlayerShot(); } else { // Check if hit a grave Grave grv = collision.collider.GetComponent <Grave>(); if (grv != null) { grv.HitByPlayerShot(); } } // Check if hit a treasure box TreasureBox treasure = collision.collider.GetComponent <TreasureBox>(); if (treasure != null) { treasure.Destroy(); } // Always destroy the shot when hits something this.Destroy(); }
protected override void OnAddGameElement(GameElement gameElement) { if (!gameElement.Name.EndsWith("__sceneEditorElement") && gameElement.HasComponent(out MeshRenderer renderer)) { var points = new Vector3f[renderer.MeshFilter.Entry.NumVertices]; for (int i = 0; i < points.Length; i++) { points[i] = renderer.MeshFilter.Mesh.MeshData.Positions[renderer.MeshFilter.Entry.BaseVertex + i]; } var aabb = BoundingBox.CreateFromPoints(points); _boundingBoxes.Add(gameElement, new BoundingBox(aabb.Min * 1.05f, aabb.Max * 1.05f)); var pickable = new PickableObject(); pickable.Picking += (p) => { SelectedElement = gameElement; }; gameElement.AttachComponent(pickable); } base.OnAddGameElement(gameElement); }
public override void Pull(GameElement element) { if (this.isStartedToPull) { return; } this.isStartedToPull = true; float distance = Vector3.Distance(this.content.localPosition, -this.pullerEnd.localPosition); Vector3 from = this.content.localPosition; Vector3 to = -this.pullerEnd.localPosition; Vector3 dif = to - from; float time = distance / 5; LeanTween.value(this.gameObject, f => { this.content.localPosition = from + (dif * f); }, 0, 1, time).setOnComplete(() => { this.isHidden = true; Destroy(this.content.gameObject); }); LeanTween.value(this.gameObject, f => { this.puller.transform.localScale = new Vector3(1, 1 + f, 1); }, 0, 1, 0.25f).setEase(LeanTweenType.easeOutSine); LeanTween.value(this.gameObject, f => { this.puller.transform.localScale = new Vector3(1, 1 + (1 * (1 - f)), 1); }, 0, 1, 0.25f).setEase(LeanTweenType.easeOutSine).setDelay(time); }
public override Puller[] GetPullersFor(GameElement element) { if (element == this.A) { List <Puller> pullers = new List <Puller>(); pullers.AddRange(this.BPullers); pullers.AddRange(this.DPullers); return(pullers.ToArray()); } if (element == this.B) { List <Puller> pullers = new List <Puller>(); pullers.AddRange(this.APullers); pullers.AddRange(this.CPullers); return(pullers.ToArray()); } if (element == this.C) { List <Puller> pullers = new List <Puller>(); pullers.AddRange(this.BPullers); pullers.AddRange(this.DPullers); return(pullers.ToArray()); } if (element == this.D) { List <Puller> pullers = new List <Puller>(); pullers.AddRange(this.CPullers); pullers.AddRange(this.APullers); return(pullers.ToArray()); } return(new Puller[0]); }
public void RangeAtack(GameElement target, bool enter) { GameObject bullet = GameObject.Instantiate(Resources.Load("Prefabs/Bullets")) as GameObject; bullet.transform.position = this.elementObject.transform.position; bullet.AddComponent <MoveComponent>().Init(target, enemyData.bulletsSpeed, enemyData.enemyBulletsDamage); }
public override GameElement Create(string element) { ElementType type; if (!Enum.TryParse(element.ToUpper().Replace(' ', '_'), out type)) { return(null); } GameElement gameElement = null; switch (type) { case ElementType.BUTTON: gameElement = Instantiate(m_ButtonTemplate).GetComponent <GameButton>(); break; case ElementType.TEXT_FIELD: gameElement = Instantiate(m_FieldTemplate).GetComponent <GameTextField>(); break; case ElementType.IMAGE: gameElement = Instantiate(m_ImageTemplate).GetComponent <GameImage>(); break; } gameElement.Type = type; GameElements.Add(gameElement); return(gameElement); }
/// <summary> /// Sets the audio listener of the scene. /// </summary> /// <param name="l">The audio listener.</param> public void SetAudioListener(GameElement l) { if (l.HasComponent <AudioListener>()) { _audioListener = l; } }
private static void _populateInternal(ref Gtk.TreeIter treeIter, GameElement gameElement) { foreach (var element in gameElement.Childs) { if (!element.IsSceneEditorGameElement()) { Gdk.Pixbuf icon; if (element.HasComponent <Camera>()) { icon = _cameraIcon; } else { icon = _meshIcon; } var iter = _treeStore.AppendValues(treeIter, icon, element.Name); _gameElementsPaths.Add(element, iter); if (element.HasChilds) { _populateInternal(ref iter, element); } } } }
public override void AddContentFromElement(GameElement element) { int r = (int)(element.Options.R * 255); int g = (int)(element.Options.G * 255); int b = (int)(element.Options.B * 255); string color = "background-color:rgb(" + r + "," + g + "," + b + ");"; string positionType = "position: absolute;"; string position = "left:" + element.transform.position.x + "px;top:" + (Screen.height - element.transform.position.y) + "px;"; string dims = "width:" + element.Options.Width + "px;height:" + element.Options.Height + "px;"; string disabled = element.Options.Interactable ? "" : "disabled"; switch (element.Type) { case ElementType.BUTTON: Content += "<button type='button' style='" + color + positionType + position + dims + "' " + disabled + ">" + element.Options.Content + "</button>"; break; case ElementType.TEXT_FIELD: Content += "<form><input type='text' value='" + element.Options.Content + "' style='" + color + positionType + position + dims + "' " + disabled + "></input></form>"; break; case ElementType.IMAGE: Content += "<image src='" + element.Options.Content + "' style='" + positionType + position + dims + "'></image>"; break; } }
public void ReceiveDamage(int damage, GameElement attackedElement) { float damageMultiplier = 1f; //switch (GetObjectElement()) //{ // case GameElement.Invalid: // default: // Debug.Log("<color=red>Invalid element, please check again.!!!! </color>"); // break; // case GameElement.Fire: // break; // case GameElement.Water: // break; // case GameElement.Rock: // break; // case GameElement.Tree: // break; // case GameElement.Electricity: // break; // case GameElement.Cargo: // break; //} ReduceHealth((int)(damageMultiplier * damage)); }
public void LoadObjects() { if (!System.IO.File.Exists(filename)) { Debug.Log(filename + ":File is not exist!"); return; } try { InitialObjects(); DisableAllGroup(); ClearObjectList(); createType = CreateType.none; gameElement = ObjectSaveLoad.JsonLoad <GameElement>(filename); items = gameElement.items; weapons = gameElement.weapons; races = gameElement.races; characters = gameElement.characters; SetItemType(); SetWeapon(); SetRace(); } catch (Exception ex) { Debug.LogError(ex.Message); } }
public IEnumerable <GameElement> LowPriorityGames(int page) { var lowPrioArray = db.LowPriorityGames .Include(g => g.Game) .ThenInclude(g => g.Genre) .ToArray(); var viewModel = new List <GameElement>(); foreach (var low in lowPrioArray) { string releaseDate = DateToString.GetYearOnly(low.Game.ReleaseDate); var elem = new GameElement() { Id = low.Game.GameId, GenreName = low.Game.Genre.Name, ImagePath = Util.GetImageFilePath(low.Game.ImagePath), Name = low.Game.Name, ReleaseDate = releaseDate }; viewModel.Add(elem); } return(viewModel); }
public static GameElement CreateGameElementWithParameters(Grid parent, ElementColor color, BonusType type = BonusType.None) { var element = new GameElement(color, parent); element.BonusType = type; return(element); }
public override void Execute() { //Clean up the Player's ship if (injectionBinder.GetBinding <ShipView> (GameElement.PLAYER_SHIP) != null) { ShipView shipView = injectionBinder.GetInstance <ShipView> (GameElement.PLAYER_SHIP); destroyPlayerSignal.Dispatch(shipView, true); } //Clean up rocks RockView[] rocks = gameField.GetComponentsInChildren <RockView> (); foreach (RockView rock in rocks) { destroyRockSignal.Dispatch(rock, false); } //Clean up enemies EnemyView[] enemies = gameField.GetComponentsInChildren <EnemyView> (); foreach (EnemyView enemy in enemies) { destroyEnemySignal.Dispatch(enemy, false); } //Clean up missiles MissileView[] missiles = gameField.GetComponentsInChildren <MissileView> (); foreach (MissileView missile in missiles) { GameElement id = (missile.gameObject.name.IndexOf("enemy") > -1) ? GameElement.ENEMY_MISSILE_POOL : GameElement.MISSILE_POOL; destroyMissileCommand.Dispatch(missile, id); } }
protected override GameElement[] GetOutput(GameElement element) { if (element == this.A) { switch (this.SwitchState) { case SwitchState.A: return(new[] { this.B, this.C }); case SwitchState.C: return(new[] { this.C, this.D }); case SwitchState.D: return(new[] { this.B, this.D }); } } else if (element == this.B) { switch (this.SwitchState) { case SwitchState.A: return(new[] { this.A, this.C }); case SwitchState.B: return(new[] { this.C, this.D }); case SwitchState.D: return(new[] { this.A, this.D }); } } else if (element == this.C) { switch (this.SwitchState) { case SwitchState.A: return(new[] { this.A, this.B }); case SwitchState.B: return(new[] { this.B, this.D }); case SwitchState.C: return(new[] { this.A, this.D }); } } else if (element == this.D) { switch (this.SwitchState) { case SwitchState.B: return(new[] { this.B, this.C }); case SwitchState.C: return(new[] { this.A, this.C }); case SwitchState.D: return(new[] { this.A, this.B }); } } return(new GameElement[0]); }
public void Load() { if (m_UICreator.m_OutputLanguage != OutputLanguage.JSON) { return; } string path = Path.Combine(Application.dataPath, "JSONInput"); string[] files = Directory.GetFiles(path); if (files.Length == 0) { return; } StreamReader fs = new StreamReader(files[0]); string s = fs.ReadToEnd(); fs.Close(); JsonFormat element = JsonUtility.FromJson <JsonFormat>(s); foreach (JsonElement je in element.Elements) { GameElement ge = m_Factory.Create(je.Type.ToString()); ge.SetOptions(je.Options); ge.transform.SetParent(m_ElementParent, true); ge.gameObject.transform.position = je.Position; } }
protected override GameElement[] GetOutput(GameElement element) { if (this.SwitchState == SwitchState.A || this.SwitchState == SwitchState.C) { if (element == this.A) { return(new[] { this.C }); } if (element == this.C) { return(new[] { this.A }); } } if (element == this.B) { return(new[] { this.D }); } if (element == this.D) { return(new[] { this.B }); } return(new GameElement[0]); }
public override void AddContentFromElement(GameElement element) { m_Elements.Add(new JsonElement() { Type = element.Type, Options = element.Options, Position = element.transform.position }); }
public IEnumerable <GameElement> FinishedGames(int page) { var finishedArray = db.FinishedGames .Include(g => g.GameRating) .Include(g => g.Game) .ThenInclude(g => g.Genre) .ToArray(); var viewModel = new List <GameElement>(); foreach (var finished in finishedArray) { string releaseDate = DateToString.GetYearOnly(finished.Game.ReleaseDate); var elem = new GameElement() { Id = finished.GameId, GenreName = finished.Game.Genre.Name, ImagePath = Util.GetImageFilePath(finished.Game.ImagePath), Name = finished.Game.Name, ReleaseDate = releaseDate }; viewModel.Add(elem); } return(viewModel); }
/// <summary> /// Sets the primary camera of the scene. /// </summary> /// <param name="c">The camera.</param> public void SetPrimaryCamera(GameElement c) { if (c.HasComponent <Camera>()) { _primaryCamera = c; } }
private void Tap(GameElement element, bool doubleTap = false) { if (element == null) { throw new Exception("Element not found"); } if (!element.IsActive) { throw new Exception("Element is inactive"); } // TODO: Look this up, 0, 0 is 0, 1920 for some reason // float y = DeviceInfo.Height - element.Location.Y; float y = (DeviceInfo.Height - element.Location.Y) + element.Rectangle.Height / 3; float x = element.Location.X + (element.Rectangle.Width / 3); if (element.GetType() == typeof(GameButton)) { y = DeviceInfo.Height - element.Location.Y; x = element.Location.X; } if (doubleTap) { App.DoubleTapCoordinates(x, y); } else { App.TapCoordinates(x, y); } }
private void _editorSceneGameElementRemoved(Scene scene, GameElement element) { if (scene.Started) { // Refresh the game elements tree ((MainWindow)Toplevel).RefreshGameElementsTree(); } }
/// <summary> /// Unregister a rigidbody in the scene. /// </summary> /// <param name="r">The rigidbody.</param> internal void UnregisterRigidBody(GameElement r) { if (r.HasComponent <RigidBody>()) { RigidBody rb = r.GetComponent <RigidBody>(); _space.Remove(rb.InnerRigidBody); } }
//public virtual void OnDestroy() //{ // SaveData(); //} public virtual bool CouldChangeGameElementValue(GameElement ele, int change) { if (ele != null) { return(true); } return(false); }
public static void SelectGameElement(GameElement gameElement) { if (_gameElementsPaths.ContainsKey(gameElement)) { var path = _treeStore.GetPath(_gameElementsPaths[gameElement]); _treeView.ActivateRow(path, _treeView.Columns[0]); } }
protected override bool IsElementInsideInput(GameElement element) { if (this.SwitchState == SwitchState.A || this.SwitchState == SwitchState.C) { return(this.A == element || this.C == element); } return(this.B == element || this.D == element); }
public static GameElement Import(string filename) { var _importer = new MeshImporter(filename); GameElement _mesh = _importer.GameElement; _importer.Dispose(); return(_mesh); }
void DamageGate(int troopAttackValue, GameElement attackElement, Troop _troop, Gate gateToDamage) { if(gateToDamage.CanDamageGate) { gateToDamage.TakeDamage(troopAttackValue, attackElement); KillTroop(_troop); } }
/// <summary> /// Construct, add event component update /// </summary> /// <param name="gameElement"></param> /// <param name="tapCanvas"></param> public AutomaticMove(GameElement gameElement, int speed) { this.gameElement = gameElement; this.gameElement.elementObject.GetComponent <GEComponent>().updateEvent += Move; this.gameElement.elementObject.GetComponent <GEComponent>().updateEvent += Jump; this.jet = GameObject.Find("Jet"); this.speed = speed; }
public void Init(GameElement target, int speed, int bulletDamage) { this.target = target; this.speed = speed; this.initialTargetPosition = target.elementObject.transform.position; this.bulletDamage = bulletDamage; lookAtTarget = true; }
public void selectElement( GameElement newSelectedElement ) { if (this.selectedElement) this.selectedElement.deselectElement(); if (newSelectedElement == null) { this.selectedElement = null; return; } this.selectedElement = newSelectedElement; }
public void point( GameElement pointedElement ) { // Send the selected element to the pointed element // and vice-versa! if (selectedElement) { pointedElement.sendSelection(selectedElement); selectedElement.sendSelection(pointedElement); } }
public void PlaceElement(Vector2 pos) { GameElement ge = m_Factory.Create(m_ElementSelector.GetSelectedElement().ToString()); ge.SetOptions(m_Toolbar.GetOptions()); ge.transform.SetParent(m_ElementParent, true); ge.gameObject.transform.position = pos; }
public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction) { base.onOver(geventhandler, who, direction); if (who == GameElement.MGO) { switch (World.MGO.Mode) { case MainGameObjectMode.Small: case MainGameObjectMode.Normal: geventhandler(GameEvent.gotFireFlower, new Dictionary<GameEventArg, object>()); break; case MainGameObjectMode.NormalFire: Dictionary<GameEventArg, object> pointsArgs = new Dictionary<GameEventArg,object>(); pointsArgs[GameEventArg.points] = 10; geventhandler(GameEvent.gotPoints, pointsArgs); break; } World.StickyElements.Remove(this); } }
public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction) { base.onOver(geventhandler, who, direction); if (color == BrickColor.Ice && who == GameElement.MGO && direction == GameDirection.Top) { switch (World.MGO.Direction) { case GameDirection.Left: for (int i = 0; i < 2; i++) { fillMgoMoveQueue(MoveType.goLeft); } break; case GameDirection.Right: for (int i = 0; i < 2; i++) { fillMgoMoveQueue(MoveType.goRight); } break; } } }
public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction) { base.onOver(geventhandler, who, direction); if (got < canGet && DateTime.Now > canGetNext && direction == GameDirection.Bottom && who == GameElement.MGO) { switch (btype) { case BoxType.GoodMushroom: getGoodie(BoxType.GoodMushroom); break; case BoxType.PoisonMushroom: getGoodie(BoxType.PoisonMushroom); break; case BoxType.LiveMushroom: getGoodie(BoxType.LiveMushroom); break; case BoxType.FireFlower: getGoodie(BoxType.FireFlower); break; case BoxType.ModeDependent: switch(World.MGO.Mode) { case MainGameObjectMode.Small: getGoodie(BoxType.GoodMushroom); break; case MainGameObjectMode.Normal: case MainGameObjectMode.NormalFire: getGoodie(BoxType.FireFlower); break; } break; case BoxType.Star: getGoodie(BoxType.Star); break; case BoxType.ImmortializeStar: getGoodie(BoxType.ImmortializeStar); break; } got++; canGetNext = DateTime.Now.AddMilliseconds(200); } }
public virtual bool sendSelection(GameElement selection) { return true; }
public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction) { base.onOver(geventhandler, who, direction); if (who == GameElement.MGO) { geventhandler(GameEvent.gotImmortialize, new Dictionary<GameEventArg, object>()); World.MovingElements.Remove(this); } }
void shootBullet(GameElement target) { Vector3 dist = target.transform.position - transform.position; if (dist.x >0) facing.x = 1; if (dist.x <0) facing.x = -1; if (dist.x == 0) facing.x = 0; if (dist.z >0) facing.y = 1; if (dist.z <0) facing.y = -1; if (dist.z == 0) facing.y = 0; GameObject bulletObj = Instantiate (bulletPrefab) as GameObject; bulletObj.transform.position = transform.position; bulletObj.GetComponent<Bullet>().init(new Vector3(facing.x,1,facing.y),equips.weapon_main.range); // TODO not always full weapon range when attacking }
public void setTarget(GameElement target, ActionType newAction) { this.target = target; if(target is Highlight){ this.action = newAction; Global.terrainUtils.resetHighlights(); } }
public void TakeDamage(int damage, GameElement attakerElement) { hit = true; Instantiate((GameObject)Resources.Load("Particles/Attack Particle"),transform.position,transform.rotation); int trueDamage = (int) Mathf.Round(damage * Element.GetMultiplayerForAttackerElement(attakerElement,this.troopStats.TroopElement)); troopStats.CurrentHealth -= (int)(trueDamage - (trueDamage*troopStats.Deffense)); troopAnimation.Hit (()=>{ this.hit = false; if(this.troopStats.CurrentHealth <= 0){ Destroy(this.gameObject); troopGate.TroopRemoved (this); } }); }
public virtual void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction) { if (base.Name != null && base.Name != "" && World.Script != null) World.Script.callFunction(base.Name, "onOver", geventhandler, who, direction); }
public static float GetMultiplayerForAttackerElement(GameElement attacker, GameElement defender) { string result = elementsMultiplier [(int)defender+1,(int)attacker+1]; return float.Parse (result); }
public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction) { base.onOver(geventhandler, who, direction); if (who == GameElement.MGO) GotMushroom(); }
public void TakeDamage(int damage, GameElement attakerElement) { int trueDamage = (int) Mathf.Round(damage * Element.GetMultiplayerForAttackerElement(attakerElement,this.stats.GateElement)); stats.CurrentHealth -= (int) (trueDamage - (trueDamage*stats.Deffense)); if (stats.CurrentHealth <= 0) { this.Die(); } }
/// <summary> /// Action sur un element lorsque selectionné /// </summary> /// <param name="otherElement">Element concerné</param> public virtual void Action(GameElement otherElement) { }
public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction) { base.onOver(geventhandler, who, direction); if (who == GameElement.MGO) { if (base.Name != null && base.Name != "" && World.Script != null) World.Script.callFunction(base.Name, "finishedLevel", geventhandler); Dictionary<GameEventArg, object> args = new Dictionary<GameEventArg, object>(); args[GameEventArg.nextLevel] = nextLevel; args[GameEventArg.nextLevelStartAt] = startAt; geventhandler(GameEvent.finishedLevel, args); } }