Ejemplo n.º 1
0
    public static void OnDisarmTrap(ActionSystem.ActionCompletedData data)
    {
        var trap = GameBehavior.thisGame.EntityManager.GetComponent <TrapComponent>(data.TargetID);

        if (trap == null)
        {
            return;
        }

        var skill = GameBehavior.thisGame.EntityManager.GetComponent <SkillComponent>(data.ActorID);

        if (skill == null)
        {
            return;
        }

        // Disarmed?
        bool disarmed = DisarmTrapResult(skill, trap);

        if (disarmed)
        {
            RemoveTrap(data.TargetID, trap);
        }
        else
        {
            trap.AddDisarmAttemptedBy(data.ActorID);
        }

        // Event
        GameBehavior.thisGame.EventManager.QueueEvent(RPGGameEvent.TrapDisarmAttempt, new TrapDisarmData()
        {
            ActorID = data.ActorID, ItemID = data.TargetID, Disarmed = disarmed
        });
    }
Ejemplo n.º 2
0
    public static void OnPickLock(ActionSystem.ActionCompletedData data)
    {
        var lockComp = GameBehavior.thisGame.EntityManager.GetComponent <LockComponent>(data.TargetID);

        if (lockComp == null)
        {
            return;
        }

        var skill = GameBehavior.thisGame.EntityManager.GetComponent <SkillComponent>(data.ActorID);

        if (skill == null)
        {
            return;
        }

        bool success = PickLockResult(skill, lockComp);

        if (success)
        {
            GameBehavior.thisGame.EntityManager.RemoveComponent(data.TargetID, typeof(LockComponent));
        }
        else
        {
            lockComp.AddPickLockAttempt(data.ActorID);
        }

        GameBehavior.thisGame.EventManager.QueueEvent(RPGGameEvent.PickedLock, new PickedLockData()
        {
            ActorID = data.ActorID, ItemID = data.TargetID, Success = success
        });
    }
Ejemplo n.º 3
0
    public static void ToggleOpen(ActionSystem.ActionCompletedData data)
    {
        var open = GameBehavior.thisGame.EntityManager.GetComponent <OpenComponent>(data.TargetID);

        if (open != null)
        {
            open.Open = !open.Open;
        }

        GameBehavior.thisGame.EventManager.QueueEvent((data.ActionType == RPGGameEvent.Menu_Open) ? RPGGameEvent.Opened : RPGGameEvent.Closed, new ToggleOpenData()
        {
            ActorID = data.ActorID, ItemID = data.TargetID
        });
    }
Ejemplo n.º 4
0
    public static void OnUseKey(ActionSystem.ActionCompletedData data)
    {
        var lockComp = GameBehavior.thisGame.EntityManager.GetComponent <LockComponent>(data.TargetID);

        if (lockComp == null)
        {
            return;
        }

        // Need to get key from inventory here (and maybe remove it?)
        int keyID = lockComp.KeyEntityID;

        GameBehavior.thisGame.EntityManager.RemoveComponent(data.TargetID, typeof(LockComponent));

        GameBehavior.thisGame.EventManager.QueueEvent(RPGGameEvent.UsedKey, new UsedKeyData()
        {
            ActorID = data.ActorID, ItemID = data.TargetID, KeyID = keyID
        });
    }