コード例 #1
0
    void Movement()
    {
        //Kan ikke velge og flytte ting om man holder inne control, da den brukes for å utføre handlinger med units
        if (Input.GetKey(KeyCode.LeftControl))
        {
            return;
        }

        //FLYTTE UNIT
        if (Input.GetMouseButtonUp(1))
        {
            //Om et object er vagt
            if (selectedUnits.Count > 0)
            {
                //Finner posisjon i verden utifra musepeker
                ray = camera.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, 10000, 1, QueryTriggerInteraction.Ignore))
                {
                    //For hvert av de valgte unitsene
                    foreach (Unit unit in selectedUnits)
                    {
                        //Får tak i move-komponenten
                        cMoveable = unit.GetComponent <CMoveable>();
                        //Om uniten kan flytte på seg
                        if (cMoveable != null)
                        {
                            //Sier at den skal ture
                            cMoveable.SendMessage("SetTarget", hit.point);
                        }
                    }
                }
            }
        }
    }
コード例 #2
0
    void Start()
    {
        cSelectable = GetComponent <CSelectable>(); cSelectable.unit = this;
        cMoveable   = GetComponent <CMoveable>();
        visibility  = GetComponent <Visibility>();

        StartCoroutine(UpdateEnemies());

        SetWeapon(weapon);
    }
コード例 #3
0
        public PeaEntity(float posX, float posY, double ShootSpeed, int shootDamage)
        {
            AI       = new AIPea(this);
            Layer    = 3;
            drawable = AddComponent(new CDrawable()) as CDrawable;
            moveable = AddComponent(new CMoveable()) as CMoveable;
            health   = AddComponent(new CHealth()) as CHealth;

            moveable.Speed   = new System.Drawing.Point((int)ShootSpeed, 0);
            health.InitialHP = 1;

            this.posX = posX;
            this.posY = posY;

            drawable.HitBox = new System.Drawing.Size(20, 20);
        }
コード例 #4
0
        public MeowerEntity(int posX, int posY)
        {
            Layer = 4;
            AI    = new AIMeower(this);
            Tags.Add("Meower");

            this.posX = posX;
            this.posY = posY;

            drawable = AddComponent(new CDrawable()) as CDrawable;
            moveable = AddComponent(new CMoveable()) as CMoveable;

            drawable.HitBox  = new Size(55, 54);
            drawable.Sprites = new List <string> {
                "tondeuse"
            };
        }
コード例 #5
0
        public SunEntity(int posX, int posY, int endingY)
        {
            Layer = 3;
            AI    = new AISun(this);
            Tags.Add("Sun");

            this.posX    = posX;
            this.posY    = posY;
            this.EndingY = endingY;

            drawable = AddComponent(new CDrawable()) as CDrawable;
            moveable = AddComponent(new CMoveable()) as CMoveable;
            AddComponent(new CClickable());
            AddComponent(new CDisappear(500));

            moveable.InitialSpeed = new Point(0, -50);

            drawable.HitBox  = new Size(55, 54);
            drawable.Sprites = new List <string> {
                "soleil"
            };
        }
コード例 #6
0
        public override void DoIt()
        {
            GameObject foundZombie = Global.Entities.FindAll(x => x.Tags.Contains("Zombie")).Find(zombie =>
                                                                                                  AssociatedGameObject.posX <= zombie.posX + zombie.GetComponent <CDrawable>().HitBox.Width&&
                                                                                                  AssociatedGameObject.posX + AssociatedGameObject.GetComponent <CDrawable>().HitBox.Width >= zombie.posX &&
                                                                                                  AssociatedGameObject.CorrectedY <= zombie.CorrectedY + zombie.GetComponent <CDrawable>().HitBox.Height&&
                                                                                                  AssociatedGameObject.CorrectedY + AssociatedGameObject.GetComponent <CDrawable>().HitBox.Height >= zombie.CorrectedY);

            if (foundZombie != null)
            {
                AssociatedGameObject.GetComponent <CHealth>().GetDamage(1);

                CMoveable zombieMove = foundZombie.GetComponent <CMoveable>();
                if (AssociatedGameObject.Tags.Contains("SnowPea") && zombieMove.Speed == zombieMove.InitialSpeed)
                {
                    foundZombie.GetComponent <CDrawable>().Effect = "gel";

                    zombieMove.Speed = new Point(-5, 0);
                }
                foundZombie.GetComponent <CHealth>().GetDamage(15);
            }
        }