Exemplo n.º 1
0
    void BasicAttack()
    {
        // Calc damage
        HitType hitType = HitType.Hit;
        var damage = AddVariance(player.dps);

        if (tpd.RollPercent(ChanceToMiss())) {
          hitType = HitType.Miss;
          damage = 0f;
        } else if (tpd.RollPercent(ChanceToGlance ())) {
          hitType = HitType.Glance;
          damage *= 0.5f;
        } else if (tpd.RollPercent(ChanceToCrit())) {
          hitType = HitType.Crit;
          damage *= 2f;
        }

        // TODO: Adjust value up and down for def
        //mob.ChangeStat(Stat.hp, -damage);

        var ev = new PlayerEvent();
        ev.type = PlayerEvent.Type.PlayerBasicAttack;
        ev.data[PlayerEvent.mobKey] = mob;
        ev.data[PlayerEvent.damageKey] = damage;
        ev.data[PlayerEvent.hitTypeKey] = hitType;

        sim.AddEvent(ev);
    }
Exemplo n.º 2
0
 /// <summary>
 /// Cancel a player event
 /// </summary>
 /// <param name="e">The event that you want to cancel</param>
 /// <param name="p">The Player that event is related to</param>
 public static void CancelPlayerEvent(PlayerEvent e, Player p)
 {
     //TODO
     //Add some more events to be canceled
     switch (e)
     {
         case PlayerEvent.BlockChange:
             p.cancelBlock = true;
             break;
         case PlayerEvent.PlayerChat:
             p.cancelchat = true;
             break;
         case PlayerEvent.PlayerCommand:
             p.cancelcommand = true;
             break;
         case PlayerEvent.PlayerMove:
             p.cancelmove = true;
             break;
         case PlayerEvent.MYSQLSave:
             p.cancelmysql = true;
             break;
         case PlayerEvent.PlayerRankChange:
             Group.cancelrank = true;
             break;
         case PlayerEvent.MessageRecieve:
             p.cancelmessage = true;
             break;
     }
 }
Exemplo n.º 3
0
        public Player()
            : base()
        {
            ID = "player";
            PlayerEventCallback = null;
            _lastEvent = PlayerEvent.None;

            RenderLayer = Render_Layer;
            RenderDepth = Render_Depth;

            _mapBounds = Rectangle.Empty;
            CollisionBoundingCircle = new Circle(Vector2.Zero, Body_Collision_Radius);
            Collidable = true;
            Visible = true;

            _motionEngine = new PlayerMotionEngine();
            MotionEngine = _motionEngine;

            _isSmashingSmashBlocks = false;
            _hasTouchedGoalFlag = false;
            IsExitingLevel = false;

            LastRaceRestartPointTouched = null;

            TutorialStepTrigger = null;

            ResetCollisionFlags();
        }
Exemplo n.º 4
0
 public PlayerMessage(PlayerEvent @event, int id, string name, AtBatRecord atBatRecord)
 {
     Event = @event;
     Id = id;
     Name = name;
     AtBatRecord = atBatRecord;
 }
Exemplo n.º 5
0
    public void TriggerChoice(PlayerEvent ev, string choiceKey)
    {
        Debug.Log ("Trigger choice " + choiceKey + " for event " + ev.Content);

        var interactionProcessor = new InteractionProcessor(sim);
        interactionProcessor.StoreChoice(choiceKey);

        NotificationCenter.PostNotification(Constants.OnUpdateEvents);
    }
Exemplo n.º 6
0
 public void TriggerEvent(PlayerEvent ev)
 {
     foreach (Trigger trigger in ev.Triggers) {
       var triggerProcessor = new TriggerProcessor(sim, trigger);
       triggerProcessor.Process();
       ev.hasTriggered = true;
       ev.Update();
     }
 }
Exemplo n.º 7
0
    public void AddEvent(PlayerEvent ev)
    {
        currentEventId = ev.Id;
        newEvents.Add(ev);

        if (ev.requiresInput) {
          RequireInput();
        }

        EventStore.Save(ev);
    }
Exemplo n.º 8
0
    void RenderMoveEvent(PlayerEvent ev)
    {
        Vector3 delta = (Vector3)ev.data[PlayerEvent.movementDeltaKey];
        string mover = (string)ev.data[PlayerEvent.moverKey];

        if (mover == Constants.playerContentKey) {
          MovePlayer(delta);
        } else if (mover == Constants.mobContentKey) {
          string mobId = (string)ev.data[PlayerEvent.moverIdKey];
          MoveMob(mobId, delta);
        }
    }
Exemplo n.º 9
0
    public void HandleAction(PlayerEvent _ev, string _actionKey)
    {
        ev = _ev;
        actionKey = _actionKey;

        if (actionKey == Constants.c_Pickup) {
          ev.chosenKey = Constants.c_Pickup;
          PickUp(ev);
        } else if (actionKey == Constants.c_Equip) {
          ev.chosenKey = Constants.c_Equip;
          Equip(ev);
        }
    }
Exemplo n.º 10
0
    public void Equip(PlayerEvent ev)
    {
        /*
        Debug.Log ("Loot processor is equipping " + eq.Name);
        SlotType slotType = eq.SlotType;
        Slot playerSlot = sim.player.Slots[slotType.Key];
        var prevEquipment = playerSlot.Equipment;
        playerSlot.Equipment = eq;

        SubtractPrevEquipment(prevEquipment);
        AddNewEquipment(eq);

        NotificationCenter.PostNotification(Constants.OnUpdateStats);
        */
    }
Exemplo n.º 11
0
    public void TriggerAction(PlayerEvent ev, string actionName)
    {
        Debug.Log ("Trigger action " + actionName + " for event " + ev.Content);

        if (ev.type == PlayerEvent.Type.Equipment) {
          var equipmentActionProcessor = new EquipmentActionProcessor(sim);
          equipmentActionProcessor.HandleAction(ev, actionName);
        }

        if (ev.type == PlayerEvent.Type.Consumable) {
          var consumableActionProcessor = new ConsumableActionProcessor(sim);
          consumableActionProcessor.HandleAction(ev, actionName);
        }

        NotificationCenter.PostNotification(Constants.OnUpdateEvents);
    }
Exemplo n.º 12
0
    void BasicAttack()
    {
        // Calc damage
        // TODO: Miss chance?
        // TODO: Crit chance
        // TODO: Adjust value up and down for def
        //var damage = mob.GetStatValue(Stat.dps);
        var damage = 10f;

        var ev = new PlayerEvent();
        ev.type = PlayerEvent.Type.MobBasicAttack;
        ev.data[PlayerEvent.mobKey] = mob;
        ev.data[PlayerEvent.damageKey] = damage;

        var trigger = new Trigger(Trigger.Type.PlayerStatChange);
        //trigger.data[Trigger.statKey] = Stat.hp;
        trigger.data[Trigger.statChangeAmountKey] = -damage;

        ev.Triggers.Add(trigger);

        sim.AddEvent(ev);
    }
Exemplo n.º 13
0
    GameObject CreatePlayerEventView(PlayerEvent playerEvent)
    {
        GameObject prefab = eventPrefab;
        GameObject eventObj = null;

        switch (playerEvent.type) {

        case PlayerEvent.Type.Info:
          eventObj = InstantiatePrefab(eventInfoPrefab, playerEvent);
          break;
        case PlayerEvent.Type.Transition:
          eventObj = InstantiatePrefab(eventTransitionPrefab, playerEvent);
          break;
        case PlayerEvent.Type.Equipment:
          eventObj = InstantiatePrefab(eventEquipmentPrefab, playerEvent);
          break;
        case PlayerEvent.Type.Choice:
          eventObj = InstantiatePrefab(eventChoicePrefab, playerEvent);
          break;
        case PlayerEvent.Type.PlayerBasicAttack:
          eventObj = InstantiatePrefab(eventPlayerBasicAttackPrefab, playerEvent);
          break;
        case PlayerEvent.Type.MobBasicAttack:
          eventObj = InstantiatePrefab(eventMobBasicAttackPrefab, playerEvent);
          break;
        case PlayerEvent.Type.Story:
          eventObj = InstantiatePrefab(eventStoryPrefab, playerEvent);
          break;
        case PlayerEvent.Type.Consumable:
          eventObj = InstantiatePrefab(eventConsumablePrefab, playerEvent);
          break;
        default:
          break;

        }

        return eventObj;
    }
Exemplo n.º 14
0
 private static void VerifyEventMask(PlayerEvent eventMask)
 {
     if (eventMask <= PlayerEvent.None || eventMask > event_all_mask) {
         throw new ArgumentOutOfRangeException ("eventMask", "A valid event mask must be provided");
     }
 }
Exemplo n.º 15
0
 protected abstract void ShowPlayerStatus(IAudioPlayer player, string status, PlayerEvent playerEvent);
Exemplo n.º 16
0
        public void ConnectEvent(PlayerEventHandler handler, PlayerEvent eventMask, bool connectAfter)
        {
            lock (event_handlers) {
                VerifyEventMask (eventMask);

                PlayerEventHandlerSlot slot = new PlayerEventHandlerSlot (eventMask, handler);

                if (connectAfter) {
                    event_handlers.AddLast (slot);
                } else {
                    event_handlers.AddFirst (slot);
                }
            }
        }
Exemplo n.º 17
0
        public void ModifyEvent(PlayerEvent eventMask, PlayerEventHandler handler)
        {
            lock (event_handlers) {
                VerifyEventMask (eventMask);

                LinkedListNode<PlayerEventHandlerSlot> node = FindEventNode (handler);
                if (node != null) {
                    PlayerEventHandlerSlot slot = node.Value;
                    slot.EventMask = eventMask;
                    node.Value = slot;
                }
            }
        }
Exemplo n.º 18
0
 public PlayerEventHandlerSlot(PlayerEvent mask, PlayerEventHandler handler)
 {
     EventMask = mask;
     Handler = handler;
 }
Exemplo n.º 19
0
 public void ConnectEvent(PlayerEventHandler handler, PlayerEvent eventMask)
 {
     ConnectEvent (handler, eventMask, false);
 }
Exemplo n.º 20
0
    public static PlayerEvent Transition(string name)
    {
        PlayerEvent ev = new PlayerEvent(name);
        ev.type = Type.Transition;

        return ev;
    }
Exemplo n.º 21
0
 void RevealTile(PlayerEvent ev)
 {
     Tile tile = (Tile)ev.data[PlayerEvent.tileKey];
     tile.tileObj.transform.Find("Fog").gameObject.SetActive(false);
     NextEvent();
 }
Exemplo n.º 22
0
 protected override void ShowPlayerStatus(IAudioPlayer player, string status, PlayerEvent playerEvent)
 {
     if (!IsEnabled)
     {
         return;
     }
     bool showAfterWithDelay = false;
     switch (playerEvent)
     {
         case PlayerEvent.Next:
             status = Localization.Current.Next;
             showAfterWithDelay = true;
             break;
         case PlayerEvent.Prev:
             status = Localization.Current.Previous;
             showAfterWithDelay = true;
             break;
         case PlayerEvent.Playing:
             status = TextWithIcon(">", status);
             break;
         case PlayerEvent.Current:
             status = TextWithIcon("\x07", status);
             break;
         case PlayerEvent.Voice:
             status = TextWithIcon("*", status);
             break;
         case PlayerEvent.Settings:
             status = TextWithIcon("*", status);
             showAfterWithDelay = true;
             break;
     }
     ShowPlayerStatus(player, status);
     if (showAfterWithDelay)
     {
         ShowPlayerStatusWithDelay(player);
     }
 }
Exemplo n.º 23
0
        private void OnPlayerChat(PlayerEvent e)
        {
            if (e is PlayerChatEvent)
            {
                var chat = (PlayerChatEvent)e;
                HookCalled("OnPlayerChat");
                Puts(chat.PlayerName + " : " + chat.Message);
            }

            if (e is GuildMessageEvent)
            {
                var chat = (GuildMessageEvent)e;
                HookCalled("OnPlayerChat");
                Puts("[Guild: " + chat.GuildName + "] " + chat.PlayerName + " : " + chat.Message);
            }
        }
 protected void OnEventChanged (PlayerEvent evnt)
 {
     OnEventChanged (new PlayerEventArgs (evnt));
 }
Exemplo n.º 25
0
 void SetPlayerEvent(PlayerEvent ev)
 {
     _playerEvent = ev;
     if (leftActionView != null) {
       leftActionView.playerEvent = ev;
     }
     if (rightActionView != null) {
       rightActionView.playerEvent = ev;
     }
 }
Exemplo n.º 26
0
 public static PlayerEvent Story(string text)
 {
     PlayerEvent ev = new PlayerEvent(text);
     ev.type = Type.Story;
     return ev;
 }
Exemplo n.º 27
0
        private object IOnPlayerChat(PlayerEvent e)
        {
            if (e.SenderId == 9999999999) return null;

            return Interface.CallHook("OnPlayerChat", e);
        }
Exemplo n.º 28
0
 public PlayerEventArgs(PlayerEvent @event)
 {
     [email protected] = @event;
 }
Exemplo n.º 29
0
 void OnPlayerChat(PlayerEvent e)
 {
     Player player = e.Player;
     string colortag = Convert.ToString(Config["GuildTagColor"]);
     player.DisplayNameFormat = "(" + colortag + player.GetGuild().Name + "[FFFFFF]" + ") %name%";
 }
Exemplo n.º 30
0
        protected override Serializer Deserialize(Serializer serializer)
        {
            serializer.KnownSerializedObjects.Add(_motionEngine);

            base.Deserialize(serializer);

            _hasLandedOnBlock = serializer.GetDataItem<bool>("has-landed-on-block");
            _didNotLandSafely = serializer.GetDataItem<bool>("did-not-land-safely");
            _hasTouchedGoalFlag = serializer.GetDataItem<bool>("has-touched-goal");
            _hasAlreadyTouchedGoalFlag = serializer.GetDataItem<bool>("already-touched-goal");
            _isSmashingSmashBlocks = serializer.GetDataItem<bool>("smashing-blocks");
            _motionEngine = serializer.GetDataItem<PlayerMotionEngine>("motion-engine");
            _lastEvent = serializer.GetDataItem<PlayerEvent>("last-event");

            return serializer;
        }