Subscribe() public static method

public static Subscribe ( Action callback, DataType, dataType, int id ) : void
callback Action
dataType DataType,
id int
return void
Esempio n. 1
0
    /*--------------s----------------------------------------------------------------------------------------------------
     * -- FUNCTION:  start
     * -- DATE:	   10/04/16
     * -- REVISIONS:  (V1.0)
     * -- DESIGNER:   Colin Bose
     * -- PROGRAMMER: Colin Bose
     * --
     * --
     * -- RETURNS:    void
     * --
     * -- NOTES: The constructor. Sets initial parameters
     * --
     * ----------------------------------------------------------------------------------------------------------------------*/
    void Start()
    {
        gameObject.layer = LayerMask.NameToLayer("Default");
        //bullet = (Rigidbody2D)Resources.Load("Prefabs/Bullet", typeof(Rigidbody2D));
        NetworkingManager.Subscribe(UpdateAI, DataType.AI, aiID);
        NetworkingManager.Subscribe(CreateProjectile, DataType.AIProjectile, aiID);
        rb2d = GetComponent <Rigidbody2D>();

        gameObject.layer = 2;
        parent           = gameObject.GetComponent <Building>();
        Debug.Log("Constructed");
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     lastPosition = transform.position;
     NetworkingManager.Subscribe(update_position, DataType.Player, playerID);
     NetworkingManager.Subscribe(took_damage, DataType.Hit, playerID);
     NetworkingManager.Subscribe(died, DataType.Killed, playerID);
     NetworkingManager.Subscribe(use_potion, DataType.Potion, playerID);
     NetworkingManager.Subscribe(new_stats, DataType.StatUpdate, playerID);
     GameData.PlayerPosition.Add(playerID, transform.position);
     baseClass = GetComponent <BaseClass>();
     animator  = gameObject.GetComponent <Animator>();
 }
Esempio n. 3
0
    /*---------------------------------------------------------------------------------------------------------------------
    *  -- FUNCTION: Start
    *  --
    *  -- DATE: March 9, 2016
    *  --
    *  -- REVISIONS: None
    *  --
    *  -- DESIGNER: Hank Lo, Allen Tsang
    *  --
    *  -- PROGRAMMER: Hank Lo, Allen Tsang
    *  --
    *  -- INTERFACE: void Start(void)
    *  --
    *  -- RETURNS: void
    *  --
    *  -- NOTES:
    *  -- Function that's called when the script is first executed - it initializes all required values
    *  ---------------------------------------------------------------------------------------------------------------------*/
    new void Start()
    {
        cooldowns = new float[2] {
            0.25f, 8f
        };

        healthBar            = transform.GetChild(0).gameObject.GetComponent <HealthBar>();
        _classStat           = new PlayerBaseStat(playerID, healthBar);
        _classStat.MaxHp     = 1100;
        _classStat.MoveSpeed = 6;
        _classStat.AtkPower  = 100;
        _classStat.Defense   = 25;

        base.Start();

        inSpecial = false;
        fired     = false;

        bullet = (Rigidbody2D)Resources.Load("Prefabs/SmallBullet", typeof(Rigidbody2D));
        laser  = (Rigidbody2D)Resources.Load("Prefabs/Laser", typeof(Rigidbody2D));

        var controller = Resources.Load("Controllers/gunboi") as RuntimeAnimatorController;

        gameObject.GetComponent <Animator>().runtimeAnimatorController = controller;
        mainCamera   = GameObject.Find("Main Camera").GetComponent <Camera>();
        zoomIn       = mainCamera.orthographicSize;
        visionCamera = GameObject.Find("Camera FOV").GetComponent <Camera>();
        hiddenCamera = GameObject.Find("Camera Enemies").GetComponent <Camera>();
        NetworkingManager.Subscribe(fireFromServer, DataType.SpecialCase, (int)SpecialCase.GunnerSpecial);

        //Player specific initialization
        if (playerID == GameData.MyPlayer.PlayerID)
        {
            //Starting item kit
            Inventory.instance.AddItem(12);

            // No longer needed - reference is given to this class when DynamicLight objects are created
            // Initialize Vision Cone and movement components
            //FOVCone       = transform.GetChild(1).gameObject.GetComponent<DynamicLight>();
            //FOVConeHidden     = transform.GetChild(3).gameObject.GetComponent<DynamicLight>();
            movement = gameObject.GetComponent <Movement>();

            startingOrthographicSize = mainCamera.orthographicSize;
            startingConeRadius       = FOVCone.LightRadius;
            startingRangeAngle       = FOVCone.RangeAngle;
        }

        //add gunboi attack sound
        au_simple_attack  = Resources.Load("Music/Weapons/gunboi_gun_primary") as AudioClip;
        au_special_attack = Resources.Load("Music/Weapons/gunboi_gun_secondary") as AudioClip;
        au_gunner_charge  = Resources.Load("Music/Weapons/gunboi_gun_charge") as AudioClip;
    }
Esempio n. 4
0
    /*-----------------------------------------------------------------------------------
     * -- FUNCTION:     Start
     * -- DATE:         05/03/2016
     * -- REVISIONS:    26/03/2016 - Added subscriptions to the networking manager
     * -- DESIGNER:     Joseph Tam-Huang
     * -- PROGRAMMER:   Joseph Tam-Huang
     * -- INTERFACE:    void Start()
     * -- RETURNS:  void
     * -- NOTES:
     * -- Subcribes to the NetworkingManager to listen for Item related messages
     * -- coming from the server and process them though call back functions.
     * -- Retrives the ItemManager script, the Inventory script and the player id.
     * ----------------------------------------------------------------------------------*/
    void Start()
    {
        NetworkingManager.Subscribe(ReceiveItemPickupPacket, DataType.Item, (int)ItemUpdate.Pickup);
        NetworkingManager.Subscribe(ReceiveItemDropPacket, DataType.Item, (int)ItemUpdate.Drop);
        NetworkingManager.Subscribe(ReceiveCreateWorldItemPacket, DataType.Item, (int)ItemUpdate.Create);
        NetworkingManager.Subscribe(ReceiveItemMagnetizePacket, DataType.Item, (int)ItemUpdate.Magnetize);

        _item_manager = GetComponent <ItemManager>();
        _inventory    = GameObject.Find("Inventory").GetComponent <Inventory>();
        _my_player_id = GameData.MyPlayer.PlayerID;

        audioSource = (AudioSource)gameObject.GetComponent <AudioSource>();
    }
Esempio n. 5
0
    // Called on start of game
    void Start()
    {
        // Subscribe our chat system to the TCP network
        NetworkingManager.Subscribe(UpdateChatCallBack, DataType.UI, (int)UICode.Chat);
        // Subscribe building creation to the TCP network
        NetworkingManager.Subscribe(UpdateBuildingCreationCallBack, DataType.UI, (int)UICode.BuildingCreation);
        // Subscribe building destruction to the TCP network
        NetworkingManager.Subscribe(UpdateBuildingDestructionCallBack, DataType.UI, (int)UICode.BuildingDestruction);
        switch (GameData.MyPlayer.ClassType)
        {
        case ClassType.Gunner:
            playerDp.Container.sprite = playerDp.GunnerDP;
            break;

        case ClassType.Wizard:
            playerDp.Container.sprite = playerDp.MageDP;
            break;

        case ClassType.Ninja:
            playerDp.Container.sprite = playerDp.NinjaDP;
            break;
        }
    }
Esempio n. 6
0
    /*---------------------------------------------------------------------------------------------------------------------
    *  -- FUNCTION: Start
    *  --
    *  -- DATE: March 9, 2016
    *  --
    *  -- REVISIONS: March 9th, 2016: Created the start [Allen]
    *  --            March 15th, 2016: Hooked up with Networking Manager [Allen/Carson]
    *  --            March 25th, 2016: Attached with HUD [Carson]
    *  --            April 2nd, 2016: Added sound [Eunwon]
    *  --            April 2nd, 2016: Added Aman buff [Allen]
    *  --
    *  -- DESIGNER: Allen Tsang, Carson Roscoe
    *  --
    *  -- PROGRAMMER: Allen Tsang, Carson Roscoe, Eunwon Moon
    *  --
    *  -- INTERFACE: void Start(void)
    *  --
    *  -- RETURNS: void
    *  --
    *  -- NOTES:
    *  -- Start of scripts creation. Used to instantiate variables in our case.
    *  ---------------------------------------------------------------------------------------------------------------------*/
    protected void Start()
    {
        allyKingID  = GameData.AllyKingID;
        enemyKingID = GameData.EnemyKingID;

        NetworkingManager.Subscribe(receiveAttackFromServer, DataType.Trigger, playerID);

        if (playerID == GameData.MyPlayer.PlayerID)
        {
            HUD_Manager.instance.subSkill.CoolDown  = cooldowns[0];
            HUD_Manager.instance.mainSkill.CoolDown = cooldowns[1];
            HUD_Manager.instance.playerProfile.Health.fillAmount = ClassStat.CurrentHp / ClassStat.MaxHp;
            print("Our health:" + HUD_Manager.instance.playerProfile.Health.fillAmount);
        }

        if (playerID == allyKingID)
        {
            HUD_Manager.instance.allyKing.Health.fillAmount = ClassStat.CurrentHp / ClassStat.MaxHp;
            print("Ally king:" + HUD_Manager.instance.allyKing.Health.fillAmount);
        }

        if (playerID == enemyKingID)
        {
            HUD_Manager.instance.enemyKing.Health.fillAmount = ClassStat.CurrentHp / ClassStat.MaxHp;
            print("Enemy king:" + HUD_Manager.instance.enemyKing.Health.fillAmount);
        }

        if (playerID == allyKingID || playerID == enemyKingID)
        {
            gameObject.AddComponent <AmanSelfBuff>();
        }

        //add audio component
        au_attack         = gameObject.AddComponent <AudioSource>();
        au_special_l      = Resources.Load("Music/Weapons/laugh_cut") as AudioClip;
        au_failed_special = Resources.Load("Music/Weapons/failed_special_use") as AudioClip;
    }
 // Use this for initialization
 void Start()
 {
     NetworkingManager.Subscribe(update_position, DataType.Player, 1);
 }
Esempio n. 8
0
 void Start()
 {
     NetworkingManager.Subscribe(receiveAttackFromServer, DataType.Trigger, playerID);
 }