示例#1
0
 // get the only object available
 public static SingleObject GetInstance()
 {
     if(mInstance == null){
       mInstance = new SingleObject();
     }
     return mInstance;
 }
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var groupId = GroupId.GetFirstValue(payload.Data);

            var singleElement = SingleObject.GetFirstValue(payload.Data);

            var targetElementCount = NumberOfEntries.GetFirstValue(payload.Data);

            if (!DataShare.ContainsKey(groupId))
            {
                DataShare[groupId] = new List <Object>();
            }
            DataShare[groupId].Add(singleElement);

            if (DataShare[groupId].Count >= targetElementCount)
            {
                var dataList = DataShare[groupId];
                RecombinedListTarget.SetValue(
                    (from obj in dataList select new MutableObject {
                    { "Value", obj }
                }).ToList(),
                    payload.Data);

                DataShare[groupId] = new List <Object>();

                var iterator = Router.TransmitAll(payload);
                while (iterator.MoveNext())
                {
                    yield return(null);
                }
            }
        }
示例#3
0
 public override void Buffer()
 {
     if (SingleObject.GetSingle().BG.TP.currentlife < 3)
     {
         SingleObject.GetSingle().BG.TP.currentlife++;
     }
     SoundPlayer.GetBlood_BGM();
 }
示例#4
0
        static void Singleton()
        {
            //illegal construct
            //Compile Time Error: The constructor SingleObject() is protected
            //SingleObject object = new SingleObject();


            //Get the only object available
            SingleObject obj = SingleObject.getInstance;

            obj.showMessage();
        }
        protected override void OnProcessOutputSchema(MutableObject newSchema)
        {
            RecombinedListTarget.SetValue(new List <MutableObject>
            {
                new MutableObject {
                    { "Value",
                      SingleObject.GetFirstValue(newSchema) }
                }
            }, newSchema);

            Router.TransmitAllSchema(newSchema);
        }
示例#6
0
 public override void attackHero()
 {
     Move();
     if (this.GetRectangle().IntersectsWith(SingleObject.GetSingle().BG.TP.GetRectangle()))
     {
         int life = SingleObject.GetSingle().BG.TP.currentlife;
         if (life > 0)
         {
             SingleObject.GetSingle().BG.TP.currentlife--;
             attackBack();
         }
     }
 }
示例#7
0
        public bool in_attack()  //英雄是否在怪物的攻击范围内
        {
            int hero_x = SingleObject.GetSingle().BG.TP.X;

            if (System.Math.Abs(this.X - hero_x) < 130)  //攻击范围为100
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#8
0
        public void attackBack() //击退英雄
        {
            int face;

            if (SingleObject.GetSingle().BG.TP.face == 0)
            {
                face = -1;
            }
            else
            {
                face = 1;
            }
            SingleObject.GetSingle().BG.TP.X = SingleObject.GetSingle().BG.TP.X + face * 100;
            SoundPlayer.FireATT_BGM();
        }
示例#9
0
        private void WhenMove()
        {
            if (SingleObject.GetSingle().BG.BGunder.Height < this.Y + this.Height)
            {
                this.y = SingleObject.GetSingle().BG.BGunder.Height - this.Height - 1;
            }
            int asd = SingleObject.GetSingle().BG.BGunder.GetPixel(0, 0).B;
            int val = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y + this.Height).B;

            while (val < 10)
            {
                this.y--;
                val = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y + this.Height).B;
            }
        }
示例#10
0
        public void move()
        {
            if (this.Y - 100 < 0)
            {
                this.Y = 100;
            }
            int b_up    = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y - 100).B;
            int b_down  = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y + 90 + this.speed).B;
            int b_left  = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 40 - this.speed, this.Y + 90 + this.speed).B;
            int b_right = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50 + this.speed, this.Y + 90 + this.speed).B;

            if (K_down)
            {
                K_down    = false;
                anm_frame = 0;

                Weapon w = new Weapon(this.X, this.Y, 20, 20, this);
                SingleObject.GetSingle().BG.ListWeapon.Add(w);
            }

            if (S_down && this.Y < map.Height - 120 && b_down > 250)
            {
                this.Y = this.Y + speed;
            }
            if (J_down && this.Y - 100 > 0 && b_up > 250)
            {
                J_down = false;
                this.Y = this.Y - 100;
            }
            if (A_down && this.X > map.X - 30 && b_left > 250)
            {
                if (face != 1)
                {
                    overturn();
                    face = 1;
                }
                this.X = this.X - speed;
            }
            if (D_down && this.X < map.Width - 100 && b_right > 250)
            {
                if (face != 0)
                {
                    overturn();
                    face = 0;
                }
                this.X = this.X + speed;
            }
        }
示例#11
0
        //object is made from it's hitbox (since it is 2.5D)
        public Item(SingleObject tiledObject)
            : base("hitbox.png")
        {
            //give the items x and y the value that is in tiled
            x = tiledObject.x;
            y = tiledObject.y;
            //adds graphics to the specific tile from tiled
            addGfx(tiledObject.gid);

            //Storing properties in the dictionary
            if (tiledObject.properties != null)
            {
                foreach (Property p in tiledObject.properties.Property)
                {
                    properties.Add(p.Name, p.Value);
                }
            }
        }
示例#12
0
    public void AddTriggerToObject(string name,SingleObject obj,SingleObject targetObj)
    {
        objectsDictionary.Add(name,obj);

        obj.AddCollisionObject (targetObj,(Collision)this);
    }
示例#13
0
 public void AddTriggerToObject(string name,SingleObject obj)
 {
     objectsDictionary.Add(name,obj);
 }
示例#14
0
 //read a single Tiled Object
 private void interpretObject(SingleObject tiledObject)
 {
     //create a scenery item
     Item scenery = new Item(tiledObject);
     items.Add(scenery);
     AddChild(scenery);
 }
示例#15
0
 public void AddCollisionObject(SingleObject targetObject, Collision coll)
 {
     collisionDictionary.Add (targetObject,coll);
 }
示例#16
0
 // Use this for initialization
 void Start()
 {
     so = this.gameObject.GetComponent<SingleObject> ();
 }