Inheritance: MonoBehaviour
コード例 #1
0
    // Use this for initialization
    void Start()
    {
        target = GameObject.Find("Player");
        transform.LookAt(target.transform.position);

        enemyLauncher = GameObject.Find("EnemyLauncher").GetComponent <EnemyLauncher>();
    }
コード例 #2
0
ファイル: ShootingEnemy.cs プロジェクト: BJarv/UrsaMajor
 protected override void Start()
 {
     //overrides start function of enemy.cs
     base.Start ();
     try {
         gun = transform.Find ("enemyGun").GetComponent<EnemyGun>();
     } catch {
         //Debug.Log ("No 'enemyGun' found, looking for shotgun");
         try {
             shotgun = transform.Find ("enemyShotgun").GetComponent<EnemyShotgun>();
         } catch {
             //Debug.Log ("No 'enemyShotgun' found, looking for launcher");
             try {
                 launcher = transform.Find ("missilePoint").GetComponent<EnemyLauncher>();
             } catch {
                 //Debug.Log ("No 'enemyLauncher' found, looking for lobber");
                 try {
                     lobber = transform.Find ("lobPoint").GetComponent<EnemyLobber>();
                 } catch {
                     Debug.Log ("No gun attached to a shooting enemy");
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: BirdKeeper.cs プロジェクト: BJarv/UrsaMajor
 protected override void Start()
 {
     //overrides start function of enemy.cs
     anim = GetComponent<Animator> ();
     base.Start ();
     sparks = transform.Find ("sparks").GetComponent<ParticleSystem> ();
     try {
         launcher = transform.Find ("missilePoint").GetComponent<EnemyLauncher>();
     } catch {
                 //Debug.Log ("No 'enemyLauncher' found, looking for lobber");
             }
 }
コード例 #4
0
ファイル: Enemy.cs プロジェクト: pettipas/LD28
 void Awake()
 {
     launcher = GetComponentInChildren<EnemyLauncher>();
 }
コード例 #5
0
    public void LoadLevelFromStats()
    {
        playerStats = FindObjectOfType <PlayerStatistics>();
        CreateDictionary();
        Dictionary <string, List <GameObject> > gameObjectsDictForSlowmo = new Dictionary <string, List <GameObject> >();

        List <PlayerStatistics.ObjectsData> levelObjectsData = playerStats.listOfObjects;
        int numObjects = levelObjectsData.Count;

        for (int i = 0; i < numObjects; i++)
        {
            PlayerStatistics.ObjectsData objectData = levelObjectsData[i];
            GameObject goInstance = (objectData.ObjectType == "hPlatform:") ? objectsDict["hPlatform"] : objectsDict[objectData.ObjectType];
            GameObject go         = Instantiate(goInstance, objectData.ObjectPosition, Quaternion.Euler(objectData.ObjectRotation));

            if (gameObjectsDictForSlowmo.ContainsKey(objectData.ObjectType))
            {
                gameObjectsDictForSlowmo[objectData.ObjectType].Add(go);
            }
            else
            {
                gameObjectsDictForSlowmo.Add(objectData.ObjectType, new List <GameObject> {
                    go
                });
            }


            //Debug.Log("Length is: " + objectData.ObjectType + gameObjectsDictForSlowmo[objectData.ObjectType].Count);

            // : is used to denote when count for horizontalplatform is 3
            if (objectData.ObjectType == "hPlatform:")
            {
                foreach (Transform child in go.transform)
                {
                    if (child.gameObject.name == "LR Horizontal Platform (2)" || child.gameObject.name == "LR Horizontal Platform (3)")
                    {
                        child.gameObject.SetActive(false);
                    }
                }
            }

            if (objectData.ObjectType == "bigBox")
            {
                GameObject fBox = go.transform.GetChild(0).gameObject;
                GameObject sBox = go.transform.GetChild(1).gameObject;

                PlayerStatistics.BigBoxData boxChildParams = (PlayerStatistics.BigBoxData)objectData.BigBoxParams;

                Debug.Log("First box Rotation Vector is: " + boxChildParams.FBoxRotation);
                Debug.Log("Second box Rotation Vector is: " + boxChildParams.SBoxRotation);

                fBox.transform.localPosition = boxChildParams.FBoxPos;
                fBox.transform.localScale    = boxChildParams.FBoxScale;
                fBox.transform.rotation      = Quaternion.Euler(boxChildParams.FBoxRotation);
                sBox.transform.localPosition = boxChildParams.SBoxPos;
                sBox.transform.localScale    = boxChildParams.SBoxScale;
                sBox.transform.rotation      = Quaternion.Euler(boxChildParams.SBoxRotation);
            }


            if (objectData.ObjectType == "sphere")
            {
                go.GetComponent <InitiateFall>().playerPrefab = playerPrefab;
            }

            if (objectData.ObjectScale != null)
            {
                go.transform.localScale = (Vector3)objectData.ObjectScale;
            }
            if (objectData.IsAnimationChangeRequired)
            {
                Animator goAnimator = go.GetComponentInChildren <Animator>();
                goAnimator.runtimeAnimatorController = objectData.AnimatorController;
            }

            if (objectData.ScriptParams != null)
            {
                PlayerStatistics.PlaceObjectScriptParams scriptParams = (PlayerStatistics.PlaceObjectScriptParams)objectData.ScriptParams;
                UpdatePlaceObjectScriptParams(go, scriptParams.IsRotating, scriptParams.PlaceWrtCorners, scriptParams.IsCoinOrPlayer, scriptParams.ScalingRequired, scriptParams.DynamicWidthForScaling);
            }

            if (objectData.LauncherScriptParams != null)
            {
                PlayerStatistics.EnemyLauncherScriptParams launcherScriptParams = (PlayerStatistics.EnemyLauncherScriptParams)objectData.LauncherScriptParams;
                EnemyLauncher cannon = go.GetComponentInChildren <EnemyLauncher>();
                cannon.isBlinking   = launcherScriptParams.IsBlinking;
                cannon.aimAtPlayer  = launcherScriptParams.AimAtPlayer;
                cannon.playerPrefab = playerPrefab;
            }
        }
        SetPlaySpaceAtRuntime(levelObjectsData[numObjects - 1].ObjectPosition.y + 5f);

        AddObjectsForSlowMotion(gameObjectsDictForSlowmo);
    }