Example #1
0
        public bool Event_OnNewTurn(ComponentEvent e)
        {
            // every turn move in the velocity and reduce it by some deceleration
            Vector2 delta = new Vector2(0, 0);

            while (Math.Abs(velocity.X) > 0 || Math.Abs(velocity.Y) > 0)
            {
                // simplify the direction into cardinal directions
                if (Math.Abs(velocity.X) > Math.Abs(velocity.Y))
                {
                    delta.x = Math.Sign(velocity.X);
                }
                else
                {
                    delta.y = Math.Sign(velocity.Y);
                }

                owner.FireEvent(new EMove()
                {
                    direction = delta
                });

                if (delta.Magnitude() >= velocity.Magnitude())
                {
                    break;
                }

                velocity -= delta;
            }

            velocity = new Vector2(0, 0);

            return(true);
        }
Example #2
0
        public bool Event_ReceiveDamage(ComponentEvent e)
        {
            EDoDamage damageEvent   = (EDoDamage)e;
            Entity    dmgInstigator = damageEvent.instigator;
            int       baseDamage    = damageEvent.damage;

            // Lets other components fill out the resistance value
            var resistEvent = (EResistDamage)owner.FireEvent(new EResistDamage()
            {
                baseDamage = baseDamage,
                instigator = dmgInstigator
            });

            int reducedDmg = baseDamage - resistEvent.resistance;

            if (reducedDmg < 0)
            {
                reducedDmg = 0;
            }

            // This entity has been destroyed
            health -= reducedDmg;
            if (health <= 0)
            {
                owner.FireEvent(new EDied()
                {
                    instigator = dmgInstigator
                });
                blocking = false;
                health   = 0;
            }

            return(true);
        }
Example #3
0
        public bool Event_OnOpen(ComponentEvent e)
        {
            // only worry about looking for valid key if its locked
            if (!isLocked)
            {
                return(true);
            }

            EOpen openEvent = (EOpen)e;

            // Check if the asker has a valid key
            Entity opener = openEvent.asker;

            // check if the opener has enything that can unlock this entity, if they do, it is used up
            var requestKey = (EConsumeItem)opener.FireEvent(new EConsumeItem()
            {
                itemName = keyType
            });

            // there is a valid key
            if (requestKey.hasItem)
            {
                isLocked = false;

                var getAskerName = (EGetScreenName)openEvent.asker.FireEvent(new EGetScreenName());
                var getOwnerName = (EGetScreenName)owner.FireEvent(new EGetScreenName());
                var getItemName  = (EGetScreenName)requestKey.consumedItem.FireEvent(new EGetScreenName());
                Engine.LogMessage("%2" + getAskerName.text + "% unlocks %2" + getOwnerName.text + "% with %2" + getItemName.text + "%", openEvent.asker);
            }

            // if its still locked, stop the openable event. Lock should be ranked above any component it is supposed to block
            return(!isLocked);
        }
Example #4
0
        public bool Event_AddStatList(ComponentEvent e)
        {
            List <string> stats = ((EGetStatList)e).stats;

            stats.Add("weight = " + weight);
            return(true);
        }
 public static PointerEventData Create(ComponentEvent model)
 {
     return(new PointerEventData(EventSystem.current)
     {
         position = model.TouchPoint
     });
 }
							  public void componentResized(ComponentEvent param2ComponentEvent)
							  {
								if (f.ExtendedState == 6)
								{
									;
								}
							  }
        public virtual bool Event_GetAttackRange(ComponentEvent e)
        {
            var getAttackRange = (EGetAttackRange)e;

            getAttackRange.range = maxRange;
            return(true);
        }
Example #8
0
        public bool Event_OnOpen(ComponentEvent e)
        {
            EOpen openEvent = (EOpen)e;

            // was already opened previously
            if (opened)
            {
                openEvent.wasOpened = false;
                return(true);
            }

            // and update the graphic
            owner.FireEvent(new ESetGraphic()
            {
                ch = openedCh
            });

            // most important part, set the opened flag in the event so other components can respond to this fact
            opened = true;
            openEvent.wasOpened = true;

            var getAskerName = (EGetScreenName)openEvent.asker.FireEvent(new EGetScreenName());
            var getOwnerName = (EGetScreenName)owner.FireEvent(new EGetScreenName());

            Engine.LogMessage("%2" + getAskerName.text + "% opens %2" + getOwnerName.text + "%", openEvent.asker);
            return(true);
        }
 public bool RunComponent(ComponentEvent componentEvent)
 {
     if (_componentEvents.ContainsKey(componentEvent))
     {
         foreach (var callback in _componentEvents[componentEvent])
         {
             try
             {
                 callback(this);
             }
             catch (StackOverflowException so)
             {
                 if (so == null)
                 {
                     ProgramLog.Log("Stack overflow detected while running component " + componentEvent);
                 }
                 else
                 {
                     ProgramLog.Log(so, "Stack overflow detected while running component " + componentEvent);
                 }
                 return(false);
             }
             catch (Exception e)
             {
                 ProgramLog.Log(e, "Exception running component " + componentEvent);
                 return(false);
             }
         }
     }
     return(true);
 }
Example #10
0
        public bool Event_GetSkillDescr(ComponentEvent e)
        {
            var skillDescr = (EGetSkillDescription)e;

            skillDescr.description += "Hits all enemies in %2" + ((int)radius) + "% tiles. ";
            return(true);
        }
Example #11
0
        public bool Event_OnAquire(ComponentEvent e)
        {
            World world = Engine.instance.world;

            // get the item payload of the event and add it to the internal list
            Entity newItem = ((EAquireItem)e).item;

            if (newItem != null && items.Count < size)
            {
                // check if it can be picked up
                ECanPickup carryEvent = (ECanPickup)newItem.FireEvent(new ECanPickup {
                    asker = owner
                });

                if (carryEvent.canPickup)
                {
                    world.DespawnEntity(newItem);
                    items.Add(newItem);

                    var getItemName  = (EGetScreenName)newItem.FireEvent(new EGetScreenName());
                    var getOwnerName = (EGetScreenName)owner.FireEvent(new EGetScreenName());
                    Engine.LogMessage("%2" + getOwnerName.text + "% grabs %2" + getItemName.text + "%", owner);
                }
            }

            return(true);
        }
Example #12
0
        public bool Event_GetSkillDescr(ComponentEvent e)
        {
            var skillDescr = (EGetSkillDescription)e;

            skillDescr.description += "Next attack ";
            return(true);
        }
Example #13
0
        public bool Event_GetAttrLevel(ComponentEvent e)
        {
            var    getAttr    = (EGetAttributeLevel)e;
            string targetAttr = getAttr.target;

            // the value of the attribute, to be discovered
            int  val       = 0;
            bool foundAttr = false;

            // use reflection to get the value of the attrbutes
            FieldInfo[] attributeFields = GetType().GetFields();
            foreach (FieldInfo field in attributeFields)
            {
                if (field.GetCustomAttribute <StatAttribute>() != null &&
                    field.Name.Equals(targetAttr))
                {
                    // Found the attribute, get the integer value
                    val       = (int)field.GetValue(this);
                    foundAttr = true;
                    break;
                }
            }

            if (!foundAttr)
            {
                Console.WriteLine("WARNING: AttributesComponent::Event_GetAttrLevel [" + targetAttr + "] does not exist.");
            }

            // send the value back in the event
            getAttr.level = val;
            return(true);
        }
Example #14
0
        public bool Event_GetSkillDescr(ComponentEvent e)
        {
            var skillDescr = (EGetSkillDescription)e;

            skillDescr.description += "Applies %2" + force + "% force. ";
            return(true);
        }
Example #15
0
        public bool Event_OnEquip(ComponentEvent e)
        {
            bool wasEquipped = false;

            var equipEvent = (EEquip)e;

            // get the item payload of the event and check which slot it should be equipped in
            Entity newItem = equipEvent.item;

            // ask the item if it is a weapon
            var canEquipEvent = (ECanEquip)newItem.FireEvent(new ECanEquip()
            {
                equipSlot = "weapon"
            });

            // make sure that the item is only equipped as weapon if there isnt already a weapon
            if (canEquipEvent.canEquip && weapon == null)
            {
                weapon      = newItem;
                wasEquipped = true;
            }

            // and record the fact that it was equipped in the calling event
            if (wasEquipped)
            {
                equipEvent.wasEquipped = true;
            }

            return(true);
        }
Example #16
0
        public bool Event_DoSkillEffects(ComponentEvent e)
        {
            var skillEffects = (ECompileSkillEffects)e;

            // get all of the entities in the radius, and add them to the effected entities
            AreaMap map = Engine.instance.world.currentMap;

            Entity[] hits = map.GetAllObjectsInRadius(skillEffects.baseLocation, radius);

            // add each, but also make sure not to repeat any
            foreach (Entity hit in hits)
            {
                bool newTarget = true;
                foreach (var combat in skillEffects.combats)
                {
                    if (combat.defender == hit)
                    {
                        newTarget = false;
                    }
                }

                // the list did not contain this target yet, so add an attack for it
                if (newTarget)
                {
                    skillEffects.combats.Add(new CombatInstance(skillEffects.user, hit)
                    {
                        { "skill", owner }
                    });
                }
            }

            return(true);
        }
Example #17
0
    private void OnButton1(ComponentEvent e)
    {
//        SearchYoutube(_searchField.Text);

        Debug.Log("Button1 Target:" + e.Target + " CurrentTarget:" + e.CurrentTarget);
        e.StopPropagation();
    }
        public virtual bool Event_AddStatList(ComponentEvent e)
        {
            List <string> stats = ((EGetStatList)e).stats;

            stats.Add("max range = " + maxRange);

            return(true);
        }
Example #19
0
 public void ComponentEventListener(ComponentEvent ev, Component component, object val)
 {
     if (ComponentEvent.ComponentAdd == ev || ComponentEvent.ComponentResume == ev)
     {
         AxesTab.UpdateDeviceIds();
         Controller.UpdateDevicePorts(component as LinkDevice);
     }
 }
Example #20
0
 public bool Event_OnDropAll(ComponentEvent e)
 {
     // just drop each item item at nearby location
     for (int i = items.Count - 1; i >= 0; i--)
     {
         DropItem(items[i]);
     }
     return(true);
 }
Example #21
0
        private void SpinWasher(ComponentEvent e)
        {
            var dichWasher = GetDishWasher();

            TweenShark.To(dichWasher.transform, 10,
                          new TweenOps(Ease.InOutQuad)
                          .UV3CompTo("localEulerAngles", 27000, V3Compnent.Up)
                          );
        }
Example #22
0
        public bool Event_GetScreenName(ComponentEvent e)
        {
            const string openText   = "Open ";
            const string closedText = "Closed ";

            ((EGetScreenName)e).text += opened ? openText : closedText;

            return(true);
        }
Example #23
0
        public bool Event_Activation(ComponentEvent e)
        {
            // tell the world about the code on activation
            World world = Engine.instance.world;

            world.GotoNewLevel(mapCode);

            return(true);
        }
Example #24
0
 public bool Event_GetAttackRange(ComponentEvent e)
 {
     // pass the range event on to the equipped weapon
     if (weapon != null)
     {
         weapon.FireEvent(e);
     }
     return(true);
 }
Example #25
0
 [java.attr.RetainName] public void componentResized(ComponentEvent e)
 {
     if (canvas == null ||
         canvas.getWidth() != getWidth() ||
         canvas.getHeight() != getHeight())
     {
         canvas = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
     }
 }
Example #26
0
        public bool Event_OnMove(ComponentEvent e)
        {
            EMove   moveEvent = (EMove)e;
            Vector2 moveDir   = moveEvent.direction;

            Vector2 currentPos = owner.position;
            Vector2 targetPos  = currentPos + moveDir;

            // first check if the tile is passable
            AreaMap map = Engine.instance.world.currentMap;

            if (map.CanMoveTo(targetPos.X, targetPos.Y))
            {
                // next check if there is an entity there that can be attacked
                Entity[] targets = map.GetAllObjectsAt(targetPos.X, targetPos.Y);
                bool     canPass = true;

                // check if the target blocks passage, and if so try to attack it
                if (targets.Length > 0)
                {
                    foreach (Entity target in targets)
                    {
                        EGetBlockState blocks = (EGetBlockState)target.FireEvent(new EGetBlockState()
                        {
                            asker    = owner,
                            blocking = false
                        });

                        if (blocks.blocking)
                        {
                            // first see if it can be opened
                            var openEvent = (EOpen)target.FireEvent(new EOpen {
                                asker = owner
                            });

                            // if it was not able to be opened, try attacking it
                            if (!openEvent.wasOpened)
                            {
                                owner.FireEvent(new EDoAttack()
                                {
                                    target = target
                                });
                            }

                            canPass = false;
                        }
                    }
                }

                if (canPass)
                {
                    map.MoveEntity(owner, targetPos);
                }
            }

            return(true);
        }
Example #27
0
        public bool Event_ApplyForce(ComponentEvent e)
        {
            EApplyForce forceEvent = ((EApplyForce)e);

            // set the velocity based on the weight and the force (to find acceleration)
            float acceleration = (float)forceEvent.force / (float)weight;

            velocity += forceEvent.direction * acceleration;
            return(true);
        }
Example #28
0
        public bool Event_GetTargets(ComponentEvent e)
        {
            AreaMap map         = Engine.instance.world.currentMap;
            var     targetEvent = (ETargetSkill)e;

            Entity[] targets = map.GetAllObjectsInRadius(targetEvent.location, radius);
            targetEvent.targets.AddRange(targets);

            return(true);
        }
Example #29
0
        public bool Event_CreateAttack(ComponentEvent e)
        {
            // just pass the attack building responsibility on to the weapon itself
            if (weapon != null)
            {
                weapon.FireEvent(e);
            }

            return(true);
        }
Example #30
0
 /// <summary>
 /// Delegate callback for listening to device events.
 /// </summary>
 /// <param name="d"></param>
 /// <param name="e"></param>
 /// <param name="v"></param>
 public void ComponentLinkListener(ComponentEvent ev, Component component, object val)
 {
     if (component == IoLinkDevice)
     {
         if (ComponentEvent.ReadComplete == ev)
         {
             ReadQueue.TryAdd(val as byte[]);
         }
     }
 }
		public void SetVisible(ComponentEvent visible) {
			Visible = visible;
		}
		public void SetDrawOrder(ComponentEvent drawOrder) {
			DrawOrder = drawOrder;
		}
 public void componentHidden(ComponentEvent e)
 {
 }
            public void componentMoved(ComponentEvent e)
            {

            }
            public void componentResized(ComponentEvent e)
            {
                var c = e.getComponent();

                content.Size = new System.Drawing.Size(c.getWidth(), c.getHeight());
            }
 public void componentShown(ComponentEvent e)
 {
 }
 public TDSMComponentAttribute(ComponentEvent componentEvent)
 {
     this.ComponentEvent = componentEvent;
 }