예제 #1
0
    public override void OnPickup()
    {
        PlayerData.instance.AddModule(Prefab);
        Qvent qvent = new Qvent(QventType.REMOVED_FROM_GAME_WORLD, typeof(FloatingItem), this);

        foreach (QventHandler l in Listeners)
        {
            l.HandleQvent(qvent);
        }
        Destroy(gameObject);
    }
예제 #2
0
 public void HandleQvent(Qvent q)
 {
     switch (q.QventType)
     {
     case QventType.DESTROYED:
         if (q.PayloadType.IsAssignableFrom(typeof(Ship)))
         {
             Observers.Remove(((Ship)q.Payload).gameObject);
         }
         break;
     }
 }
예제 #3
0
    public virtual void Repair(float time)
    {
        int repamt = Mathf.Max((int)((time / RepairTime) * maxhp), 1);

        DoHeal(repamt);

        Qvent q = new Qvent(QventType.HEALED);

        foreach (QventHandler handy in Listeners)
        {
            handy.HandleQvent(q);
        }
    }
예제 #4
0
        }         // switches to the idle subroutine

        public void HandleQvent(Qvent qvent)
        {
            // Gonna need some complex event handling logic...
            if (Triggers.ContainsKey(qvent.QventType))
            {
                if (ActiveProcess)
                {
                    ActiveProcess.OnInterrupt();
                }

                StellarSubroutine result = Triggers [qvent.QventType];
                Triggers [qvent.QventType].HandleQvent(qvent);
            }
        }
    public void OnPortDisconnected(Module mod)
    {
        moduleConnectHelper(mod, false);
        moduleEnableHelper(mod, false, mod.portType == Port.PortType.MAIN);

        Qvent q = new Qvent(QventType.STRUCTURE_CHANGED);

        foreach (QventHandler handy in Listeners)
        {
            handy.HandleQvent(q);
        }

        mod.UnregisterListener(this);
    }
예제 #6
0
    public override void OnPickup()
    {
        PlayerData.instance.AddScrap(ScrapValue);
        Qvent qvent = new Qvent(QventType.REMOVED_FROM_GAME_WORLD, typeof(FloatingItem), this);

        foreach (QventHandler l in Listeners)
        {
            l.HandleQvent(qvent);
        }

        WidgetManager.instance.CreateFloatingNumber(Color.gray, Color.clear, 1, 0.2f, ScrapValue.ToString()).transform.position = transform.position;

        Destroy(gameObject);
    }
예제 #7
0
 public void HandleQvent(Qvent e)
 {
     Debug.Log("QVENT RECVD: " + e.QventType.ToString());
     if (triggers.ContainsKey(e.QventType))
     {
         Debug.Log("FOUND QVENT");
         foreach (Decision dec in triggers[e.QventType])
         {
             if (dec.EventRun(Time.fixedDeltaTime, e.PayloadType, e.Payload) == NodeStatus.RUNNING)
             {
                 runningDecisions.Add(dec);
             }
         }
     }
     // @TODO: Think about how you can combine EventRun into Process
 }
예제 #8
0
    public void HandleQvent(Qvent myQvent)
    {
        switch (myQvent.QventType)
        {
        case QventType.DAMAGED:
            Refresh();
            break;

        case QventType.STRUCTURE_CHANGED:
            Refresh();
            break;

        case QventType.HEALED:
            Refresh();
            break;
        }
    }
예제 #9
0
    public virtual void HandleQvent(Qvent qvent)
    {
        switch (qvent.QventType)
        {
        case QventType.DAMAGED:
            SetState(ShipState.COMBAT);
            CombatCooldownTimer = SpaceGameGlobal.COMBAT_COOLDOWN;
            break;

        case QventType.DESTROYED:
            if (qvent.PayloadType.IsAssignableFrom(typeof(Ship)))
            {
                Listeners.Remove((Ship)qvent.Payload);
            }
            break;
        }
    }
예제 #10
0
 public override void HandleQvent(Qvent e)
 {
     Debug.Log("RECIEVED EVENT IN XOR GROUP");
     if (e.QventType == QventType.DECISION_EVENT)
     {
         List <object> list     = (List <object>)e.Payload;
         Decision      decision = (Decision)list [0];
         NodeStatus    status   = (NodeStatus)list [1];
         foreach (Decision member in GroupMembers)
         {
             if (decision != member)
             {
                 source.QueueRemove(member);
             }
         }
     }
 }
예제 #11
0
    public virtual void DoDamage(int amt)
    {
        if (invincible || amt < 0)
        {
            return;
        }

        curhp = (curhp - amt <= 0)? 0 : curhp - amt;

        Qvent q = new Qvent(QventType.DAMAGED);

        foreach (QventHandler handy in Listeners)
        {
            handy.HandleQvent(q);
        }

        if (curhp <= 0)
        {
            Die();
        }
    }
예제 #12
0
    // QventHandler Interface Declaration

    public void HandleQvent(Qvent qvent)
    {
        switch (qvent.QventType)
        {
        case QventType.DESTROYED:
            // remove destroyed ship from tracking
            if (qvent.PayloadType == typeof(Ship))
            {
                RemoveFromSector(((Ship)qvent.Payload).gameObject);
            }
            break;

        case QventType.REMOVED_FROM_GAME_WORLD:
            // remove destroyed object from tracking
            if (qvent.PayloadType == typeof(FloatingItem))
            {
                RemoveFromSector(((FloatingItem)qvent.Payload).gameObject);
            }
            break;
        }
    }
예제 #13
0
    public void Update()
    {
        Vector2 dir = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;

        if (dir.magnitude <= range)
        {
            if (InRange)
            {
                return;
            }
            else
            {
                InRange = true;
                Qvent q = new Qvent(QventType);
                DispatchEvent(q);
            }
        }
        else
        {
            InRange = false;
        }
    }
예제 #14
0
    public override void Die()
    {
        this.enabled = false;
        foreach (Port p in ports)
        {
            p.Eject();
        }
        foreach (Port p in mainPorts)
        {
            p.Eject();
        }

        int num = UnityEngine.Random.Range(1, 11);

        for (int i = 0; i < num; i++)
        {
            GameObject  debris = WidgetManager.instance.CreateFloatingScrap(ScrapCost / 100, transform.position);
            Rigidbody2D rb     = debris.GetComponent <Rigidbody2D> ();
            Vector2     away   = UnityEngine.Random.insideUnitCircle;
            rb.velocity      = away.normalized * UnityEngine.Random.value;
            gameObject.layer = LayerMask.NameToLayer("PlayerOnly");
            rb.gravityScale  = 0;
        }

        Qvent qvent = new Qvent(QventType.DESTROYED, typeof(Ship), this);

        foreach (QventHandler listeners in Listeners)
        {
            Debug.Log("Listener Found");
            listeners.HandleQvent(qvent);
        }

        if (IsPlayer)
        {
            SpaceGameManager.instance.PlayerDied();
        }

        GameObject.Destroy(this.gameObject);
    }
예제 #15
0
 public virtual void HandleQvent(Qvent Qvent)
 {
     Debug.LogWarning("Unimplemented HandleQvent called in Group<NEW_AIBase>");
 }