Exemplo n.º 1
0
    public override void Execute()
    {
        TextAsset file = Resources.Load("Items") as TextAsset;

        var n = SimpleJSON.JSON.Parse(file.text);


        for (int i = 0; i < n.Count; i++)
        {
            IweaponHealhPackModel whModel = injectionBinder.GetInstance <IweaponHealhPackModel>();
            string itemName = n [i]["name"].Value;
            string itemTag  = n [i] ["tag"].Value;
            float  posX     = n [i] ["posX"].AsFloat;
            float  posY     = n [i] ["posY"].AsFloat;
            float  posZ     = n [i] ["posZ"].AsFloat;
            whModel.itemEvent = n [i] ["event"];
            whModel.itemPower = n [i] ["power"].AsFloat;
            whModel.name      = itemName;

            GameObject goItem = GameObject.Instantiate(Resources.Load(n [i]["prefabName"].Value)) as GameObject;

            goItem.name = itemName;
            goItem.AddComponent <ItemView> ();
            goItem.transform.position = new Vector3(posX, posY, posZ);
            goItem.tag = itemTag;

            goItem.transform.parent = contextView.transform;


            injectionBinder.Bind(itemName).To(whModel);
        }
    }
Exemplo n.º 2
0
    public override void Execute()
    {
        string viewName = (string)evt.data;
        IweaponHealhPackModel itemModel = injectionBinder.GetBinding(viewName).value as IweaponHealhPackModel;

        if (myPlayer.armed == false)
        {
            GameObject goItem = GameObject.Instantiate(Resources.Load(itemModel.name)) as GameObject;
            goItem.name = itemModel.name;
            goItem.AddComponent <WeaponView>();
            WeaponView wv = goItem.GetComponent <WeaponView> ();
            wv.updatePower(itemModel.itemPower);
            goItem.transform.SetParent(contextView.GetComponentInChildren <PlayerView>().transform);
            goItem.transform.localPosition = Vector3.right;
            myPlayer.armed = true;
        }

        else
        {
            GameObject player = GameObject.Find("Player");

            dispatcher.Dispatch(GameEvents.TO_DESTROY_ITEM, player.transform.GetChild(0).name);
            dispatcher.Dispatch(GameEvents.READY_TO_INSTANTIATE_ITEM, player.transform.GetChild(0).name);

            myPlayer.armed = false;

            dispatcher.Dispatch(GameEvents.ON_EQUIP_WEAPON, itemModel.name);
        }
    }
Exemplo n.º 3
0
    public override void Execute()
    {
        string viewName = (string)evt.data;
        IweaponHealhPackModel itemModel = injectionBinder.GetBinding(viewName).value as IweaponHealhPackModel;

        //Debug.Log (itemModel.itemEvent);
        dispatcher.Dispatch(itemModel.itemEvent, viewName);
    }
Exemplo n.º 4
0
    public override void Execute()
    {
        string viewName = (string)evt.data;

        IweaponHealhPackModel itemModel = injectionBinder.GetBinding(viewName).value as IweaponHealhPackModel;

        GameObject goItem = GameObject.Instantiate(Resources.Load(itemModel.name)) as GameObject;

        goItem.name = itemModel.name;
        goItem.gameObject.AddComponent <ItemView> ();
        goItem.transform.localPosition = myplayer.position + new Vector3(0f, -0.5f, 1f);
        goItem.transform.parent        = contexView.transform;
    }
Exemplo n.º 5
0
    public override void Execute()
    {
        string viewName = (string)evt.data;
        IweaponHealhPackModel itemModel = injectionBinder.GetBinding(viewName).value as IweaponHealhPackModel;

        playerHealth = myPlayer.health;

        newHealth = playerHealth + itemModel.itemPower;

        if (newHealth > MAX_HEALTH)
        {
            newHealth = playerHealth;
        }


        dispatcher.Dispatch(GameEvents.ON_HEALTH_BONUS_ADDED, newHealth);
    }