예제 #1
0
    // Use this for initialization
    void Start()
    {
        /* every component that is a PlayerComponent must be initialized with the base player */
        myInput      = (PlayerInput)GetComponent <PlayerInput>().initialize(this);
        myMovement   = (PlayerMovement)GetComponent <PlayerMovement>().initialize(this);
        myStats      = (PlayerStats)GetComponent <PlayerStats>().initialize(this);
        myNetworking = (PlayerNetworking)GetComponent <PlayerNetworking>().initialize(this);
        myGUI        = (PlayerGUI)GetComponent <PlayerGUI>().initialize(this);
        myEffects    = (PlayerEffects)GetComponent <PlayerEffects>().initialize(this);
        PlayerAbility[] abilityCandidates = GetComponents <PlayerAbility>();
        myAbilities = new PlayerAbility[abilityCandidates.Length];
        int myAbilityIndex = 0;

        foreach (PlayerAbility playerAbility in abilityCandidates)
        {
            myAbilities[myAbilityIndex] = (PlayerAbility)playerAbility.initialize(this);
            myAbilityIndex++;
        }


        myAnimator           = transform.GetChild(0).GetComponent <Animator>();
        myRigid              = GetComponent <Rigidbody>();
        myCollider           = GetComponent <Collider>();
        myNoFrictionCollider = transform.Find("NoFrictionSides").GetComponent <Collider>();
        myNetworkIdentity    = this.GetComponent <NetworkIdentity>();

        if (isServer)
        {
            playerId = Guid.NewGuid().ToString();
        }
    }
예제 #2
0
    void Awake()
    {
        mFunc = GetComponent <MouseFunctions>();
        //bhandler = GetComponent<BuildHandler> ();

        UIClickFX      = (AudioClip)(Resources.Load("Sounds/UIButtonclick", typeof(AudioClip)));
        needMoneySound = (AudioClip)(Resources.Load("Sounds/needMoney", typeof(AudioClip)));
        sourceSFX      = Camera.main.GetComponent <AudioSource>();
        BGMusic        = Camera.main.transform.GetComponentInChildren <AudioSource> ();

        //spawner = spawnObject.GetComponent<SpawnUnit> ();

        normalCursor = (Texture2D)Resources.Load("Sprites/Arrow");
        buildCursor  = (Texture2D)Resources.Load("Sprites/BuildCursor");
        attackCursor = (Texture2D)Resources.Load("Sprites/AttackCursor");

        orbGhost    = (GameObject)(Resources.Load("Towers/TowerGhosts/OrbGhost"));
        cannonGhost = (GameObject)(Resources.Load("Towers/TowerGhosts/CannonGhost"));
        laserGhost  = (GameObject)(Resources.Load("Towers/TowerGhosts/LaserGhost"));
        lightGhost  = (GameObject)(Resources.Load("Towers/TowerGhosts/LightGhost"));
        magicGhost  = (GameObject)(Resources.Load("Towers/TowerGhosts/MagicGhost"));
        iceGhost    = (GameObject)(Resources.Load("Towers/TowerGhosts/IceGhost"));

        myPN = GetComponent <PlayerNetworking> ();
        bank = GetComponent <Bank>();
    }
예제 #3
0
    void Awake()
    {
        kf = GetComponent <KeyboardFunctions>();

        grid     = GetComponent <Grid>();
        bhandler = GetComponent <BuildHandler> ();
        bank     = GetComponent <Bank>();
        pathfind = GetComponent <PathFind>();
        pn       = GetComponent <PlayerNetworking> ();

        wallGhostLoaded = (GameObject)(Resources.Load("Walls/WallGhost"));

        wallIcon   = Resources.Load <Sprite> ("Sprites/WallIcon");
        orbIcon    = Resources.Load <Sprite> ("Sprites/OrbIcon");
        cannonIcon = Resources.Load <Sprite> ("Sprites/CannonIcon");
        laserIcon  = Resources.Load <Sprite> ("Sprites/LaserIcon");
        iceIcon    = Resources.Load <Sprite> ("Sprites/IceIcon");
        lightIcon  = Resources.Load <Sprite> ("Sprites/LightIcon");
        magicIcon  = Resources.Load <Sprite> ("Sprites/MagicIcon");

        rangeIndicator = (GameObject)(Resources.Load("UI/RangeIndicator"));

        highlightCastleMaterial = (Material)(Resources.Load("Materials/Outlined_Object"));

        BuildFX          = (AudioClip)(Resources.Load("Sounds/BuildingPlacement", typeof(AudioClip)));
        needMoneySound   = (AudioClip)(Resources.Load("Sounds/needMoney", typeof(AudioClip)));
        cannotBuildSound = (AudioClip)(Resources.Load("Sounds/CannotBuild", typeof(AudioClip)));
        selectSound      = Resources.Load <AudioClip> ("Sounds/CarDoorClose");

        sourceSFX = Camera.main.GetComponent <AudioSource>();
    }
예제 #4
0
    public void setTarget(PlayerNetworking _target)
    {
        if (_target == null)
        {
            Debug.LogError("<Color=Red><a>Missing</a></Color> PlayMakerManager target for PlayerUI.SetTarget.", this);
            return;
        }

        target = _target;
        if (playerNameText != null)
        {
            playerNameText.text = target.GetComponent <PhotonView>().Owner.NickName;
        }
    }
예제 #5
0
    void RpcImpact(Color Color_, Vector3 Position_, Vector3 Normal_)
    {
        _PaintManager.NewParticle(Color_, Position_, Normal_);

        // Green splash dmg
        if (Color_ == Color.green)
        {
            Collider[] Coll_ = Physics.OverlapSphere(Position_, 1);

            foreach (Collider hit in Coll_)
            {
                PlayerNetworking PN_ = hit.transform.gameObject.GetComponent <PlayerNetworking>();

                if (PN_ != null && gameObject.name != "Local player")
                {
                    PN_.RpcResolveHit(FireDamage * 0.5f);
                }
            }
        }
    }
예제 #6
0
    void Awake()
    {
        //Set References
        //============================================================
        kf   = GetComponent <KeyboardFunctions> ();
        mf   = GetComponent <MouseFunctions> ();
        bank = GetComponent <Bank>();
        pn   = GetComponent <PlayerNetworking> ();

        //Pre-load Objects
        //============================================================
        //Walls
        wall2Way   = (GameObject)(Resources.Load("Walls/Wall2Way"));
        wall3Way   = (GameObject)(Resources.Load("Walls/Wall3Way"));
        wall4Way   = (GameObject)(Resources.Load("Walls/Wall4Way"));
        wallEnd    = (GameObject)(Resources.Load("Walls/WallEnd"));
        wallCorner = (GameObject)(Resources.Load("Walls/WallCorner"));
        wallSolo   = (GameObject)(Resources.Load("Walls/WallSolo"));

        wallFloorOpen  = (GameObject)(Resources.Load("Walls/WallDoorOpen"));
        wallFloorClose = (GameObject)(Resources.Load("Walls/WallDoorClose"));

        //Towers
        orbTower    = (GameObject)(Resources.Load("Towers/BasicOrbTower"));
        cannonTower = (GameObject)(Resources.Load("Towers/CannonTower"));
        laserTower  = (GameObject)(Resources.Load("Towers/LaserTower"));
        iceTower    = (GameObject)(Resources.Load("Towers/IceTower"));
        lightTower  = (GameObject)(Resources.Load("Towers/LightTower"));
        magicTower  = (GameObject)(Resources.Load("Towers/MagicTower"));

        //Audio References
        sourceSFX = Camera.main.GetComponent <AudioSource> ();

        needMoneySound   = (AudioClip)(Resources.Load("Sounds/needMoney", typeof(AudioClip)));
        cannotBuildSound = (AudioClip)(Resources.Load("Sounds/CannotBuild", typeof(AudioClip)));
    }
예제 #7
0
    void CmdPlayerShot(float FireRate_, float FireDamage_)
    {
        // Fire rate
        if (Time.time > FireRateCD && WeaponManager_.GetCurAmmo() > 0)
        {
            // Set time when the gun can fire again
            FireRateCD = Time.time + FireRate_;
            // Remove a bullet from the ammo system
            WeaponManager_.ShotCurAmmo();
            // Show muzzle smoke out of the gun
            RpcMuzzle();
            // Play audio
            RpcPlayAudio();

            RaycastHit hit;
            Vector3    rayPos = CameraPos.transform.position + CameraPos.transform.forward;

            Debug.DrawRay(rayPos, CameraPos.transform.forward, Color.green, 0.1f, true);
            if (Physics.Raycast(rayPos, CameraPos.transform.forward, out hit, 10))
            {
                Debug.Log("Hit: " + hit.transform.gameObject.name);
                Debug.DrawRay(hit.point, hit.normal, Color.red, 2.0f);


                // Color
                switch (FireColor)
                {
                case FireColors.blue:
                    RpcImpact(Color.blue, hit.point, hit.normal);
                    break;

                case FireColors.red:
                    RpcImpact(Color.red, hit.point, hit.normal);
                    break;

                case FireColors.yellow:
                    RpcImpact(Color.yellow, hit.point, hit.normal);
                    break;

                case FireColors.green:
                    RpcImpact(Color.green, hit.point, hit.normal);
                    break;

                case FireColors.white:
                    RpcImpact(Color.white, hit.point, hit.normal);
                    break;
                }

                // Get Other playerNetworking
                PlayerNetworking PN_ = hit.transform.gameObject.GetComponent <PlayerNetworking>();

                // Check if there is a PlayerNetworking script on the object
                if (PN_ != null)
                {
                    PN_.RpcResolveHit(FireDamage_);
                }
            }


            Debug.Log(WeaponManager_.GetCurAmmo());
        }
        else
        if (WeaponManager_.GetCurAmmo() < 1)
        {
            // No ammo left

            Debug.Log("No ammo left");
        }
    }