Ejemplo n.º 1
0
    public List <MinionInfoSerialization> GetAllMinions()
    {
        List <MinionController> minions = new List <MinionController>();

        minions.AddRange(blueMinions);
        minions.AddRange(redMinions);
        List <MinionInfoSerialization> serializableMinions = new List <MinionInfoSerialization>();

        foreach (var m in minions)
        {
            MinionInfoSerialization ms = new MinionInfoSerialization()
            {
                directionX = m.Direction.x,
                directionY = m.Direction.y,
                size       = m.Size.x,
                speed      = m.Speed,
                team       = (int)m.Team,
                positionX  = m.transform.position.x,
                positionY  = m.transform.position.y
            };
            serializableMinions.Add(ms);
        }
        return(serializableMinions);
    }
    public void Init(MinionInfoSerialization mc)
    {
        speed                = mc.speed;
        direction            = new Vector2(mc.directionX, mc.directionY);
        team                 = (MinionTeamsEnum)mc.team;
        size                 = Vector3.one * mc.size;
        transform.localScale = size;
        transform.position   = new Vector3(mc.positionX, mc.positionY, 0.0f);

        switch (team)
        {
        case MinionTeamsEnum.Blue:
            attachedRenderer.material.color = Color.blue;
            break;

        case MinionTeamsEnum.Red:
            attachedRenderer.material.color = Color.red;
            break;
        }
        MinionsManager.instance.AddMinionToList(this);

        SimulationController.OnSpawnFinished    += OnSpawnFinished_Action;
        SimulationController.OnFinishSimulation += OnFinishSimulation_Action;
    }