예제 #1
0
    public override void TakeMsg(ActorModel who, EventMsg msg)
    {
        switch (msg.Type)
        {
        case EventType.TakeDmg:
            int amount = msg.Amount;
            God.C.AddAction(new TakeDamageAction(who, amount));
            ModelManager.TakeDamage(amount);
            return;

        case EventType.PlayerInput:
            if (msg.Dir == Inputs.Left)
            {
                who.Move(-1, 0);
            }
            else if (msg.Dir == Inputs.Right)
            {
                who.Move(1, 0);
            }
            else if (msg.Dir == Inputs.Up)
            {
                who.Move(0, 1);
            }
            else if (msg.Dir == Inputs.Down)
            {
                who.Move(0, -1);
            }
            return;

        case EventType.GetName:
            msg.Text += " PLAYER";
            return;
        }
    }
예제 #2
0
    public override void TakeMsg(ActorModel who, EventMsg msg)
    {
        switch (msg.Type)
        {
        case EventType.GetBumped:
            God.C.AddAction(new BumpAction(msg.Source, who.Location.x, who.Location.y));
            who.View.GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
            who.View.transform.GetComponentInParent <TileView>().GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
            msg.Source.TakeMsg(new EventMsg(EventType.TakeDmg, who, 2));
            return;

        case EventType.GetName:
            msg.Text += " " + "FakeKey";
            return;

        case EventType.KeyMove:
            //Debug.Log("Move");
            //who.Move()

            if (who.View.movement < God.GSM.monsterRound)
            {
                //God.GSM.monsterMovement++;
            }
            else if (who.View.movement == God.GSM.monsterRound)
            {
                int rand = Random.Range(0, 2);
                Debug.Log(rand);
                if (rand == 1)
                {
                    if (who.Location.x > GameSettings.playerX)
                    {
                        who.Move(-1, 0);
                    }
                    else if (who.Location.x < GameSettings.playerX)
                    {
                        who.Move(1, 0);
                    }
                }
                else if (rand == 0)
                {
                    if (who.Location.y > GameSettings.playerY)
                    {
                        who.Move(0, -1);
                    }
                    else if (who.Location.y < GameSettings.playerY)
                    {
                        who.Move(0, 1);
                    }
                }
                //God.GSM.AS.PlayOneShot(God.GSM.StompClip);
                who.View.movement = 0;
            }
            return;
        }
    }
예제 #3
0
    public override void TakeMsg(ActorModel who, EventMsg msg)
    {
        switch (msg.Type)
        {
        case EventType.TakeDmg:
            int amount = msg.Amount;
            God.C.AddAction(new TakeDamageAction(who, amount));
            ModelManager.TakeDamage();
            return;

        case EventType.PlayerInput:
            if (msg.Dir == Inputs.Left && God.GSM.wallLimit != 0)
            {
                //Debug.Log(ModelManager.GetActor(who.ID));
                who.Move(-1, 0);
            }
            else if (msg.Dir == Inputs.Right && God.GSM.wallLimit != 1)
            {
                who.Move(1, 0);
            }
            else if (msg.Dir == Inputs.Up && God.GSM.wallLimit != 2)
            {
                who.Move(0, 1);
            }
            else if (msg.Dir == Inputs.Down && God.GSM.wallLimit != 3)
            {
                who.Move(0, -1);
            }
            foreach (TileModel tm in ModelManager.GetTiles())
            {
                tm.View.ControllerCheck(tm.View);
            }
            GameSettings.playerX = who.Location.x;
            GameSettings.playerY = who.Location.y;
            God.GSM.currentMoves++;
            return;

        case EventType.GetName:
            msg.Text += " PLAYER";
            return;
            //case EventType.MonsterMove:
            //who.Move((int)Random.Range(-1, 1), (int)Random.Range(-1, 1));
            //return;
        }
    }
예제 #4
0
    public override void TakeMsg(ActorModel who, EventMsg msg)
    {
        bool key = false;

        switch (msg.Type)
        {
        case EventType.GetBumped:
            if (God.GSM.keyIsVisible)
            {
                ActorModel bumper = msg.Source;
                if (bumper.Type == ThingTypes.Player)
                {
                    TileModel loc = who.GetLocation();
                    bumper.HasKey = true;

                    God.GSM.hasKey = true;
                    Debug.Log("KEY IS " + key);
                    who.LeaveTile(who.GetLocation());
                    bumper.SetLocation(loc);
                    who.View.GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
                    who.View.transform.GetComponentInParent <TileView>().GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
                    God.C.AddAction(new GainKeyAction(bumper, who));
                }
            }
            return;

        case EventType.GetName:
            msg.Text += " KEY";
            return;

        case EventType.KeyMove:
            //Debug.Log("KEY IS MOVING");
            if (!God.GSM.hasKey)
            {
                if (God.GSM.keyMovement < God.GSM.monsterRound)
                {
                    God.GSM.keyMovement++;
                }
                else if (God.GSM.keyMovement == God.GSM.monsterRound)
                {
                    int rand = Random.Range(0, 2);
                    Debug.Log(rand);
                    if (rand == 1)
                    {
                        if (who.Location.x > GameSettings.playerX)
                        {
                            who.Move(-1, 0);
                        }
                        else if (who.Location.x < GameSettings.playerX)
                        {
                            who.Move(1, 0);
                        }
                    }
                    else if (rand == 0)
                    {
                        if (who.Location.y > GameSettings.playerY)
                        {
                            who.Move(0, -1);
                        }
                        else if (who.Location.y < GameSettings.playerY)
                        {
                            who.Move(0, 1);
                        }
                    }
                    //God.GSM.AS.PlayOneShot(God.GSM.StompClip);
                    God.GSM.keyMovement = 0;
                }
            }
            return;
        }
    }
예제 #5
0
    public override void TakeMsg(ActorModel who, EventMsg msg)
    {
        switch (msg.Type)
        {
        case EventType.GetBumped:
            ActorModel bumper = msg.Source;
            if (bumper.Type == ThingTypes.Player)
            {
                if (God.GSM.scoreIsVisible)
                {
                    TileModel loc = who.GetLocation();
                    who.View.GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
                    who.View.transform.GetComponentInParent <TileView>().GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
                    God.C.AddAction(new GetScoreAction(bumper, who));
                    who.Despawn();
                    ModelManager.ChangeScore(1);
                    bumper.SetLocation(loc);
                }
            }
            return;

        case EventType.GetName:
            msg.Text += " SCORETHING";
            return;

        case EventType.ScoreMove:
            if (God.GSM.scoreMovement < God.GSM.monsterRound)
            {
                God.GSM.scoreMovement++;
            }
            else if (God.GSM.scoreMovement == God.GSM.monsterRound)
            {
                int rand = Random.Range(0, 2);
                Debug.Log(rand);
                if (rand == 1)
                {
                    if (who.Location.x > GameSettings.playerX)
                    {
                        who.Move(-1, 0);
                    }
                    else if (who.Location.x < GameSettings.playerX)
                    {
                        who.Move(1, 0);
                    }
                }
                else if (rand == 0)
                {
                    if (who.Location.y > GameSettings.playerY)
                    {
                        who.Move(0, -1);
                    }
                    else if (who.Location.y < GameSettings.playerY)
                    {
                        who.Move(0, 1);
                    }
                }
                //God.GSM.AS.PlayOneShot(God.GSM.StompClip);
                God.GSM.scoreMovement = 0;
            }
            return;
        }
    }
예제 #6
0
    public override void TakeMsg(ActorModel who, EventMsg msg)
    {
        switch (msg.Type)
        {
        case EventType.GetBumped:
            God.C.AddAction(new BumpAction(msg.Source, who.Location.x, who.Location.y));
            who.View.GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
            who.View.transform.GetComponentInParent <TileView>().GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
            msg.Source.TakeMsg(new EventMsg(EventType.TakeDmg, who, God.Library.GetMonster(who.Species).Damage));
            //who.Despawn();
            return;

        case EventType.GetName:
            msg.Text += " " + God.Library.GetMonster(who.Species).Type;
            return;

        case EventType.MonsterMove:
            //Debug.Log("Move");
            //who.Move()

            if (God.GSM.monsterMovement < God.GSM.monsterRound)
            {
                God.GSM.monsterMovement++;
            }
            else if (God.GSM.monsterMovement == God.GSM.monsterRound)
            {
                int rand = Random.Range(0, 2);
                Debug.Log(rand);
                if (rand == 1)
                {
                    if (who.Location.x > GameSettings.playerX)
                    {
                        who.Move(-1, 0);
                    }
                    else if (who.Location.x < GameSettings.playerX)
                    {
                        who.Move(1, 0);
                    }
                }
                else if (rand == 0)
                {
                    if (who.Location.y > GameSettings.playerY)
                    {
                        who.Move(0, -1);
                    }
                    else if (who.Location.y < GameSettings.playerY)
                    {
                        who.Move(0, 1);
                    }
                }
                God.GSM.AS.PlayOneShot(God.GSM.StompClip);
                God.GSM.monsterMovement = 0;
            }
            return;
        }



        //int rand = Random.Range(0, 3);
        //Debug.Log(rand);
        //if (rand == 1) {
        //    if (who.Location.x > GameSettings.playerX)
        //    {
        //        who.Move(-1, 0);
        //    }
        //    else if (who.Location.x < GameSettings.playerX)
        //    {
        //        who.Move(1, 0);
        //    }
        //}
        //else if (rand == 0) {
        //    if (who.Location.y > GameSettings.playerY)
        //    {
        //        who.Move(0, -1);
        //    }
        //    else if (who.Location.y < GameSettings.playerY)
        //    {
        //        who.Move(0, 1);
        //    }
        //}
        //else if (rand == 2)
        //{
        //    if (who.Location.y > GameSettings.playerY)
        //    {
        //        who.Move(0, 0);
        //    }
        //    else if (who.Location.y < GameSettings.playerY)
        //    {
        //        who.Move(0,0);
        //    }
        //}
        //who.Move(who.Location.x);
        //if(who.Location.x == -(GameSettings.MapSizeX / 2)) {
        //    who.Move((int)Random.Range(0, 1), 0);
        //}
        //if (who.Location.x == (GameSettings.MapSizeX / 2)) {
        //    who.Move((int)Random.Range(-1, 0), 0);
        //}
        //if (who.Location.y == -(GameSettings.MapSizeY / 2)) {
        //    who.Move(0, (int)Random.Range(0, 1));
        //}
        //if (who.Location.y == (GameSettings.MapSizeY / 2))
        //{
        //    who.Move(0, (int)Random.Range(-1, 0));
        //}
        //else {
        //    who.Move(0, 0);
        //}

        //if (who.Location.y > -(GameSettings.MapSizeY / 2) &&
        //    who.Location.y < (GameSettings.MapSizeY / 2) &&
        //    who.Location.x > -(GameSettings.MapSizeX / 2) &&
        //    who.Location.x > (GameSettings.MapSizeX / 2)) {
        //    who.Move((int)Random.Range(-1, 1), (int)Random.Range(-1, 1));
        //}
        //        return;
        //}
    }