Exemplo n.º 1
0
        public Player(PlayerIndex playerIndex, Texture2D backTexture, Texture2D frontTexture, int health,
            string damageSound, Sprite sprite, uint collisionDamage, float speed, bool horizontal, 
            bool vertical, Texture2D bulletTexture, Vector2 shotOffset, int bulletHits,
            uint bulletDamage, float bulletSpeed, float shotTime)
            : base("Player", "Players", health, damageSound, sprite, true, collisionDamage, "Enemies")
        {
            index = playerIndex;

            OnCollision += new Action1(collideWith);
            OnDamage += new Action(damageEffect);

            horizontalMovement = horizontal;
            verticalMovement = vertical;
            this.speed = speed;

            barTextureBack = backTexture;
            barTextureFront = frontTexture;

            this.bulletTexture = bulletTexture;
            this.shotOffset = shotOffset;
            this.bulletHits = bulletHits;
            this.bulletDamage = bulletDamage;
            this.bulletSpeed = bulletSpeed;
            this.shotTime = shotTime;
        }
Exemplo n.º 2
0
        public Player(PlayerIndex playerIndex, Texture2D backTexture, Texture2D frontTexture, int health,
                      string damageSound, Sprite sprite, uint collisionDamage, float speed, bool horizontal,
                      bool vertical, Texture2D bulletTexture, Vector2 shotOffset, int bulletHits,
                      uint bulletDamage, float bulletSpeed, float shotTime)
            : base("Player", "Players", health, damageSound, sprite, true, collisionDamage, "Enemies")
        {
            index = playerIndex;

            OnCollision += new Action1(collideWith);
            OnDamage    += new Action(damageEffect);

            horizontalMovement = horizontal;
            verticalMovement   = vertical;
            this.speed         = speed;

            barTextureBack  = backTexture;
            barTextureFront = frontTexture;

            this.bulletTexture = bulletTexture;
            this.shotOffset    = shotOffset;
            this.bulletHits    = bulletHits;
            this.bulletDamage  = bulletDamage;
            this.bulletSpeed   = bulletSpeed;
            this.shotTime      = shotTime;
        }
Exemplo n.º 3
0
 //
 // Aplique-se a função 'action' a cada elemento de 'source'.
 //
 public static void Apply(this IEnumerable source, Action1 action)
 {
     foreach (Object obj in source)
     {
         action(obj);
     }
 }
Exemplo n.º 4
0
 //
 // Aplique-se a função 'action' a cada elemento de 'source'.
 //
 public static void Apply <T>(this IEnumerable <T> source, Action1 <T> action)
 {
     foreach (T obj in source)
     {
         action(obj);
     }
 }
Exemplo n.º 5
0
    public override void OnShow(params object[] parameters)
    {
        InputManager.Instance.Mode = InputMode.Inventory;

        InventoryType type = (InventoryType)parameters[0];
        Inventory     inv  = parameters[1] as Inventory;

        toolbar.UpdateInput(type);
        tooltip.UpdateTooltip(selectedButton);
        firstInput  = null;
        secondInput = null;

        OpenInventory(inv, type);

        if (type == InventoryType.PLAYER)
        {
            playerEquipement = parameters[2] as Equipement;
            playerEquipement.myButtonList = myButtonList;
            FindAllButtonEquip();
        }
        else if (type == InventoryType.PLAYER_SHOP)
        {
            FindAllButtonEquip();
        }
        else if (type == InventoryType.PLAYER_STORE)
        {
            FindAllButtonEquip();
        }
    }
Exemplo n.º 6
0
    static void Main()
    {
        Action1 <Animal> act1 = ActOnAnimal;
        Action1 <Dog>    dog1 = act1;

        dog1(new Dog());
    }
Exemplo n.º 7
0
 public Enemy(int health, string damageSound, Sprite sprite, uint collisionDamage, float speed)
     : base("", "Enemies", health, damageSound, sprite, true, collisionDamage, "Players", "Projectiles")
 {
     this.speed = speed;
     OnCollision += new Action1(collideWith);
     OnDamage += new Action(damageEffect);
 }
Exemplo n.º 8
0
 public Enemy(int health, string damageSound, Sprite sprite, uint collisionDamage, float speed)
     : base("", "Enemies", health, damageSound, sprite, true, collisionDamage, "Players", "Projectiles")
 {
     this.speed   = speed;
     OnCollision += new Action1(collideWith);
     OnDamage    += new Action(damageEffect);
 }
Exemplo n.º 9
0
        public Powerup(int amount, string damageSound, Sprite sprite, float speed)
            : base("", "Powerups", 1, damageSound, sprite, true, 0, "Players")
        {
            this.speed  = speed;
            this.amount = amount;

            OnCollision += new Action1(collision);
        }
Exemplo n.º 10
0
        public Powerup(int amount, string damageSound, Sprite sprite, float speed)
            : base("", "Powerups", 1, damageSound, sprite, true, 0, "Players")
        {
            this.speed = speed;
            this.amount = amount;

            OnCollision += new Action1(collision);
        }
Exemplo n.º 11
0
        internal void AddAction_1(double id, string content)
        {
            Action1 action1 = new Action1();

            action1.ID      = id;
            action1.Content = content;
            _actions_1.Add(action1);
        }
Exemplo n.º 12
0
            public ConsoleMethod_Action1(Action1 method, MethodDescription description) : base(description)
            {
                if (method == null)
                {
                    throw new ArgumentNullException(nameof(method));
                }

                this.method = method;
            }
Exemplo n.º 13
0
        private static void ContrvarianceDelegates()
        {
            Action1 <BaseExample> baseClassAction = ActionOnBaseClass;
            // contrvariance
            Action1 <DerivedExample> derivedClassAction = baseClassAction;

            Action2 <BaseExample> baseClassAction2 = ActionOnBaseClass;
            // error
            //Action2<DerivedExample> derivedClassAction2 = baseClassAction2;
        }
        public void TestCreateStaticSetter1()
        {
            string  n        = nameof(ClassWithStaticFields.StaticValueField);
            Action1 setValue = typeof(ClassWithStaticFields).CreateStaticSetter(n);

            setValue(456);
            Assert.AreEqual(456, ClassWithStaticFields.StaticValueField);
            setValue(0);
            Assert.AreEqual(0, ClassWithStaticFields.StaticValueField);
        }
        public void TestCreateStaticSetter2()
        {
            string  n        = nameof(ClassWithStaticFields.StaticTextField);
            Action1 setValue = typeof(ClassWithStaticFields).CreateStaticSetter(n);

            setValue("ABC");
            Assert.AreEqual("ABC", ClassWithStaticFields.StaticTextField);
            setValue(null);
            Assert.AreEqual(null, ClassWithStaticFields.StaticTextField);
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            Action1 <Animal> act1 = ActOnAnimal;

            Action1 <Dog> dog1 = act1;

            //dog1(new Dog());

            act1(new Dog());
        }
        public void TestCreateStaticSetter3()
        {
            string  n        = nameof(ClassWithStaticFields.StaticEnumField);
            Action1 setValue = typeof(ClassWithStaticFields).CreateStaticSetter(n);

            setValue(EnumForTest.Example);
            Assert.AreEqual(EnumForTest.Example, ClassWithStaticFields.StaticEnumField);
            setValue(EnumForTest.None);
            Assert.AreEqual(EnumForTest.None, ClassWithStaticFields.StaticEnumField);
        }
Exemplo n.º 18
0
        //-------------------------------------------------------------------------
        public override BehaviorComponent child()
        {
            Action1 action_dummy = new Action1(BehaviorTree, actionDummy);

            var node_playermanual = new Selector(BehaviorTree, action_dummy);

            Conditional con_canmanual = new Conditional(BehaviorTree, conditionPlayerManual);
            var         child         = new Sequence(BehaviorTree, con_canmanual, node_playermanual);

            return(child);
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            Func1 <Cat>    cat    = () => new Cat();
            Func1 <Animal> animal = cat;

            Action1 <Animal> act1 = (ani) => { Console.WriteLine(ani); };
            Action1 <Cat>    cat1 = act1;

            Console.WriteLine(animal());
            cat1(new Cat());
        }
Exemplo n.º 20
0
        static void Main()
        {
            Action1 <object> d1 = n => { };
            Action1 <string> d2 = d1;
            // stringからobjectの変換はコンパイル不可
            // d3 = d4;

            ISample <Sub>  s = new Im();
            ISample <Base> b = s;
            // BaseらSubの変換はコンパイル不可
            // s = b;
        }
Exemplo n.º 21
0
        public void removeEventListener(string type, Action1 <Event> action)
        {
            switch (type)
            {
            case Event.ADDED_TO_STAGE:
                addedToStageActions -= action;
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 22
0
            public static Model Create(
                Action1 action,
                SupportedActions supportedActions
                )
            {
                var _this = new Model();

                _this.origin.action           = action;
                _this.origin.supportedActions = supportedActions;
                _this.RevertChanges();

                return(_this);
            }
Exemplo n.º 23
0
 public Trigger Clone()
 {
     return(new Trigger()
     {
         Name = Name,
         PersistantType = PersistantType,
         House = House,
         EventControl = EventControl,
         Event1 = Event1.Clone(),
         Event2 = Event2.Clone(),
         Action1 = Action1.Clone(),
         Action2 = Action2.Clone()
     });
 }
        public void TestCreateAction1b()
        {
            string  n   = nameof(ExampleClass2.Increment);
            Action1 inc = Accelerator.CreateAction1(typeof(ExampleClass2).GetMethod(n, Type.EmptyTypes));

            var o = new ExampleClass2();

            o.Increment();
            Assert.AreEqual(1, o.Value);
            inc(o);
            Assert.AreEqual(2, o.Value);
            inc(o);
            inc(o);
            Assert.AreEqual(4, o.Value);
        }
 public override string ToString()
 {
     if (IsDeadlocked)
     {
         return("<DEADLOCKED>");
     }
     else if (IsTau)
     {
         return("t - " + Action1.ToString().Replace("_", ""));
     }
     else
     {
         return(Action1.ToString().Replace("_", ""));
     }
 }
Exemplo n.º 26
0
 public void StartEvent()
 {
     if (Condition1.ConditionResult() && Condition2.ConditionResult())
     {
         Action3.Execute();
     }
     else if (Condition1.ConditionResult())
     {
         Action1.Execute();
     }
     else if (Condition2.ConditionResult())
     {
         Action2.Execute();
     }
 }
Exemplo n.º 27
0
 // コンストラクタ
 public SupplyData(DateTime time, int value, Action1 action1, Action2 action2)
 {
     // 数値を記録する
     oldTime  = Utility.GetTimeStrSQLite(time);
     Time     = new ReactiveProperty <string>(oldTime);
     oldValue = value;
     Value    = new ReactiveProperty <int>(oldValue);
     // コマンドを作成する
     // つまり、「Time != oldTime または Value != oldValue」なら
     // EditCommandが有効になる
     EditCommand = Time.Select(x => (x != oldTime)).CombineLatest(
         Value.Select(y => (y != oldValue)), (x, y) => x | y).ToReactiveCommand();
     // コマンドを登録する
     EditCommand.Subscribe(_ => action1(oldTime, oldValue, Time.Value, Value.Value));
     DeleteCommand.Subscribe(_ => action2(oldTime, oldValue));
 }
Exemplo n.º 28
0
        public void addEventListener(string type, Action1 <KeyboardEvent> action)
        {
            switch (type)
            {
            case KeyboardEvent.KEY_DOWN:
                keyDownActions += action;
                break;

            case KeyboardEvent.KEY_UP:
                keyUpActions += action;
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 29
0
    public IAction CreateAction(ACTION_ID id)
    {
        IAction Action = null;

        switch (id)
        {
        case ACTION_ID.ACTION_1: Action = new Action1(); break;

        case ACTION_ID.ACTION_2: Action = new Action2(); break;

        case ACTION_ID.ACTION_3: Action = new Action3(); break;

        case ACTION_ID.ACTION_4: Action = new Action4(); break;

        case ACTION_ID.ACTION_5: Action = new Action5(); break;

        case ACTION_ID.ACTION_6: Action = new Action6(); break;

        case ACTION_ID.ACTION_DasheBackward: Action = new ActionDashBackward(); break;

        case ACTION_ID.ACTION_DasheForward: Action = new ActionDashForward(); break;

        case ACTION_ID.ACTION_Jab: Action = new ActionJab(); break;

        case ACTION_ID.ACTION_Kick: Action = new ActionKick(); break;

        case ACTION_ID.ACTION_MoveAttack1: Action = new ActionMoveAttack1(); break;

        case ACTION_ID.ACTION_MoveAttack2: Action = new ActionMoveAttack2(); break;

        case ACTION_ID.ACTION_Punch: Action = new ActionPunch(); break;

        case ACTION_ID.ACTION_RangeAttack1: Action = new ActionRangeAttack1(); break;

        case ACTION_ID.ACTION_RangeAttack2: Action = new ActionRangeAttack2(); break;

        case ACTION_ID.ACTION_SpecialAttack1: Action = new ActionSpecialAttack1(); break;

        case ACTION_ID.ACTION_SpecialAttack2: Action = new ActionSpecialAttack2(); break;

        case ACTION_ID.ACTION_Uppercut: Action = new ActionUppercut(); break;

        default: Action = new NullAction(); break;
        }
        ControllerCenter.Instance.ActionSystem.Add((uint)(Time.realtimeSinceStartup) * 100, Action);
        return(Action);
    }
Exemplo n.º 30
0
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
        //     Public Method
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

        /// <summary>
        /// Action を実行する。
        /// </summary>
        /// <param name="params">引数</param>
        public void Execute(params object[] @params)
        {
            switch (Type)
            {
            case ActionType.Type1:
                Action1.Invoke();
                break;

            case ActionType.Type2:
                Action2.Invoke((int)@params[0]);
                break;

            case ActionType.Type3:
                Action3.Invoke((int)@params[0], (T)@params[1]);
                break;
            }
        }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            //Interface Covariance
            IMessageRecieved <object> objMessageRX = new DataTX <string>();

            //Interface Contravariance
            IMessageSend <string> objMessageSend = new DataTX <object>();


            //Delegate Covariance
            Func1 <Cao> delegateCao = new Func1 <Cao>(CreateCaoInstance);
            Cao         objCao      = delegateCao();

            Console.WriteLine("Convariance:" + objCao);
            Func1 <Animal> delegateAnimal = delegateCao;
            Animal         objAnimal      = delegateAnimal();

            Console.WriteLine("Covariance:" + objAnimal);

            //Delegate Contravariance
            Action1 <Animal> act1 = new Action1 <Animal>(DisplayCaoInstance);

            act1(new Animal());
            Action1 <Cao> cao1 = act1;

            cao1(new Cao());

            //Icomparer Contravariance
            BaseComparer <Manager> objComparer = new BaseComparer <Manager>();
            List <Manager>         managerList = new List <Manager>();

            managerList.Add(new Manager("Damasceno", 1));
            managerList.Add(new Manager("Vitor", 2));
            managerList.Sort(objComparer);

            List <Employee> employeeList = new List <Employee>();

            employeeList.Add(new Employee("Damasceno", 1));
            employeeList.Add(new Employee("Vitor", 2));

            //employeeList.Sort(objComparer);
            managerList.ForEach(e => Console.WriteLine(e.ID + " " + e.Name));

            Console.ReadKey();
        }
        public void TestCreateAction1d()
        {
            string  n   = nameof(ExampleStruct2.Increment);
            Action1 inc = Accelerator.CreateAction1(typeof(ExampleStruct2).GetMethod(n, Type.EmptyTypes));

            var unboxed = new ExampleStruct2();

            unboxed.Increment();
            Assert.AreEqual(1, unboxed.Value);

            IExample boxed = unboxed;

            inc(boxed);
            Assert.AreEqual(2, boxed.Value);
            inc(boxed);
            inc(boxed);
            Assert.AreEqual(4, boxed.Value);
        }
Exemplo n.º 33
0
        public void removeEventListener(string type, Action1 <MouseEvent> action)
        {
            switch (type)
            {
            case MouseEvent.MOUSE_DOWN:
                mouseDownActions -= action;
                break;

            case MouseEvent.MOUSE_MOVE:
                mouseMoveActions -= action;
                break;

            case MouseEvent.MOUSE_UP:
                mouseUpActions -= action;
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 34
0
 public HealthPack(int amount, Sprite sprite, float speed)
     : base(amount, "Health", sprite, speed)
 {
     OnCollision += new Action1(collide);
 }
Exemplo n.º 35
0
 public Bubble(int amount, Sprite sprite, float speed)
     : base(amount, "Bubble", sprite, speed)
 {
     OnCollision += new Action1(collide);
     OnDeath += bubbleSound;
 }
Exemplo n.º 36
0
 public Projectile(int hits, Sprite sprite, uint collisionDamage, Vector2 velocity, params string[] collisionGroups)
     : base("", "Projectiles", hits, "", sprite, true, collisionDamage, collisionGroups)
 {
     OnCollision += new Action1(collide);
     Sprite.Velocity = velocity;
 }