Ejemplo n.º 1
1
 // Awake
 void Awake()
 {
     myRigidbody = GetComponent<Rigidbody>();
     myRigidbody.maxAngularVelocity = 25f;
     myTransform = GetComponent<Transform>();
     cameraTransform = Camera.main.GetComponent<Transform>();
 }
    protected void OnCollisionWithEnemy(GameObject enemy, float power)
    {
        power *= WeaponPowerMiltiplier;
        enemyTransform = enemy.transform;
        enemyController = enemy.GetComponent<FightEnemyController>();

        if (power < MinForceToHit)
            return;

        // Blood
        newBloodParticle = Instantiate<GameObject>(BloodParticles);
        newBloodParticle.transform.position = enemyTransform.position;
        newBloodParticle.transform.up = (enemyTransform.position - selfTransform.position).normalized;
        Destroy(newBloodParticle, 1);

        // Do damage
        enemyController.DoDamage(Mathf.Clamp(power, MinForceToHit, MaxForceToHit));
        //print(WeaponTypeName + ": " + hitVelocityMagnitude.ToString());

        // Damage Text
        newDamageText = Instantiate<GameObject>(DamageText);
        newDamageTextText = newDamageText.GetComponent<Text>();
        newDamageTextText.rectTransform.SetParent(WorldCanvas, false);
        newDamageTextText.rectTransform.position = enemyTransform.position + new Vector3(0f, 0.5f, 0f); ;
        newDamageTextText.text = string.Format("{0}", power.ToString("F0"));
    }
Ejemplo n.º 3
1
    // Use this for initialization
    void Awake()
    {
        player = GameObject.FindGameObjectWithTag ("Player").transform;
        playerOrgin = player.position;

        path2 = new []{ new Vector3(10.0f,20.0f,40f), new Vector3(10f,10f,20f),
            playerOrgin, new Vector3(0f,10f,-10f), new Vector3( 0f, -5f, -20f), new Vector3(10f,-10f,5f),
            new Vector3(5f,5f,15f), new Vector3(0f,20f,20f)};

        path3 = new []{ new Vector3(30.0f,6.0f,60f), new Vector3(9f,40f,40f),
            new Vector3(15.2f,2f,20f), new Vector3(0f,0f,5f), new Vector3( 4f, 7f, -30f), new Vector3(16f,4f, 5f)};

        path4 = new []{ new Vector3(20.0f,30.0f,60f), new Vector3(5f,70f,40f),
            new Vector3(28.2f,21f,20f), new Vector3(0f,0f,5f), new Vector3( 4f, 7f, -30f), new Vector3(16f,4f, 5f)};

        path5 = new []{ new Vector3(20.0f,30.0f,60f), new Vector3(5f,-70f,30f),
            new Vector3(11.2f,16f,20f), new Vector3(0f,0f,5f), new Vector3( 4f, -17f, -30f), new Vector3(16f,4f, 5f)};

        aiShip = FindObjectOfType <Rigidbody> ();
        launcher = GetComponent<MLauncher> ();

        path = path2;
        target = path[0];
        bound = new Bounds (path[0], new Vector3(1f,1f,1f));
    }
Ejemplo n.º 4
1
 private void Awake()
 {
     button = transform.FindChild("Button");
     thebase = transform.FindChild("Base");
     startScale = button.localScale;
     targetScale = thebase.localScale;
 }
 void Start()
 {
     _t = transform;
     _animator = GetComponent<Animator>();
     _controller = GetComponent<CharacterController>();
     _rigidbody = GetComponent<Rigidbody>();
 }
Ejemplo n.º 6
0
    public void Init(Transform canvasTransform, float killedUnitsCount, float timePassed)
    {
        transform.SetParent(canvasTransform);
        (transform as RectTransform).anchoredPosition = Vector3.zero;

        _killedUnitsCount.text = string.Format(Constants.Common.GameEndedText, killedUnitsCount, timePassed);
    }
Ejemplo n.º 7
0
    private void handleHierarchy(Transform root, Dictionary<string,bool> presenceByName, Dictionary<string,Transform> originalsByName)
    {
        List<Transform> allChildren = new List<Transform>( presenceByName.Count );

        concatenateHierarchy(root, allChildren);

        foreach(Transform t in allChildren)
        {
            GameObject go = t.gameObject;

            //bool thisIsTheSkinnedMeshRenderer = go.renderer != null && go.renderer is SkinnedMeshRenderer;

            string key = t.name;

            bool shouldBePresent = presenceByName.ContainsKey(key) ? presenceByName[key] : false;

            shouldBePresent &= originalsByName[key].gameObject.activeSelf;

            go.SetActive( shouldBePresent ); // || thisIsTheSkinnedMeshRenderer;
        }

        foreach(Transform t in allChildren)
        {
            string key = t.name;

            if(originalsByName.ContainsKey(key))
            {
                Transform original = originalsByName[key];

                t.localPosition = original.localPosition;
                t.localRotation = original.localRotation;
                t.localScale = original.localScale;
            }
        }
    }
Ejemplo n.º 8
0
 public void Awake()
 {
     //Initialize components
     nav = GetComponent<NavMeshAgent>();
     player = GameObject.FindWithTag("Player").transform;
     playerHealth = player.GetComponent<PlayerHealth>();
 }
Ejemplo n.º 9
0
 void Awake()
 {
     masterGame = GetComponentInParent<MasterGameScript>();
     foreground = transform.Find ("Camera/Foreground");
     level = GetComponentInChildren<LevelScript>();
     waves = new List<Wave>();
 }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        GameObject go = GameObject.FindGameObjectWithTag("Player");

        target = go.transform;
        maxDistance = 2;
    }
Ejemplo n.º 11
0
	void DrawLayoutOutline(Transform t) {
		var layout = t.GetComponent<tk2dUILayout>();
		if (layout != null) {
			Vector3[] p = new Vector3[] {
				new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
				new Vector3(layout.bMax.x, layout.bMin.y, 0.0f),
				new Vector3(layout.bMax.x, layout.bMax.y, 0.0f),
				new Vector3(layout.bMin.x, layout.bMax.y, 0.0f),
				new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
			};
			for (int i = 0; i < p.Length; ++i) p[i] = t.TransformPoint(p[i]);
			Handles.color = Color.magenta;
			Handles.DrawPolyLine(p);

			var sizer = t.GetComponent<tk2dUILayoutContainerSizer>();
			if (sizer != null) {
				Handles.color = Color.cyan;
				float arrowSize = 0.3f * HandleUtility.GetHandleSize(p[0]);
				if (sizer.horizontal) {
					Handles.ArrowCap(0, (p[0] + p[3]) * 0.5f, Quaternion.LookRotation(p[1] - p[0]), arrowSize);
					Handles.ArrowCap(0, (p[1] + p[2]) * 0.5f, Quaternion.LookRotation(p[0] - p[1]), arrowSize);
				} else {
					Handles.ArrowCap(0, (p[0] + p[1]) * 0.5f, Quaternion.LookRotation(p[3] - p[0]), arrowSize);
					Handles.ArrowCap(0, (p[2] + p[3]) * 0.5f, Quaternion.LookRotation(p[0] - p[3]), arrowSize);
				}
			}
		}

		for (int i = 0; i < t.childCount; ++i)
			DrawLayoutOutline(t.GetChild(i));
	}
    public override void OnDropStop(Transform objectBellow)
    {
        base.OnDropStop (objectBellow);

        if (!objectBellow.gameObject.layer.Equals (LayerMask.NameToLayer ("Crates")))
            Open ();
    }
Ejemplo n.º 13
0
 private void AddChildren(Transform parent, List<Transform> list)
 {
     list.Add (parent);
     foreach (Transform t in parent) {
         AddChildren (t, list);
     }
 }
Ejemplo n.º 14
0
	//add chain into chains list
	public void AddChain(Transform chain)
	{
		//if chains list isn't created, create it
		if(chains == null)
			chains = new List<Transform>();

		//if linerenderer isn't added, add it
		if(lineRend == null)
		{
			lineRend = GetComponent<LineRenderer>();

			if(!lineRend)
			{
				lineRend = gameObject.AddComponent<LineRenderer>();
				lineRend.material = ropeMaterial;
			}
		}

		chains.Add (chain);	//add chain into chains list

		//fill LineRenderer component's positions
		lineRend.SetVertexCount (chains.Count);
		lineRend.SetPosition (chains.Count - 1, chains[chains.Count - 1].position);

		startChainCount = chains.Count;
	}
Ejemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     player = PlayerController.MyTransform;
     candig = false;
     diggableItem.SetActive(false);
     digtime = 0f;
 }
Ejemplo n.º 16
0
 void Start()
 {
     audioSource = GetComponent<AudioSource>();
     driver = GameObject.Find("GameDriver") as GameObject;
     shadow = transform.FindChild("RimShadow");
     shadowDistance = (transform.position - shadow.position).magnitude;
 }
Ejemplo n.º 17
0
    public override void OnCreate()
    {
        base.OnCreate();

		m_collectBoard = mUIObject.transform.FindChild("CollectBoard");
		m_jellyBoard = mUIObject.transform.FindChild("JellyBoard");
        m_scoreBoard = mUIObject.transform.FindChild("ScoreBoard");
		m_nutBoard = mUIObject.transform.FindChild("NutBoard");
		
        m_gameFailedBoard = mUIObject.transform.FindChild("FailedBoard");
        m_resortBoard = mUIObject.transform.FindChild("ResortBoard");
        m_autoResortBoard = mUIObject.transform.FindChild("AutoResortBoard");
        m_sugarCrushBoard = mUIObject.transform.FindChild("SugarCrushBoard");

        m_stepLimitBoard = mUIObject.transform.FindChild("StepLimitBoard");
        m_timeLimitBoard = mUIObject.transform.FindChild("TimeLimitBoard");

        nut1Label = GetChildComponent<NumberDrawer>("NutCount1");
        nut2Label = GetChildComponent<NumberDrawer>("NutCount2");
		nut1Icon = GetChildComponent<UISprite>("NutIcon1");
		nut2Icon = GetChildComponent<UISprite>("NutIcon2");
        nutSplash = GetChildComponent<UISprite>("NutSplash");

		jellyIcon = GetChildComponent<UISprite>("SingleIcon");
		jellyDoubleIcon = GetChildComponent<UISprite>("DoubleIcon");
		jellySplash = GetChildComponent<UISprite>("JellySlash");

        m_background = GetChildComponent<UISprite>("Background");

        for (int i = 0; i < 3; ++i )
        {
            collectLabel[i] = GetChildComponent<UILabel>("CollectCount" + (i + 1));
            collectIcon[i] = GetChildComponent<UISprite>("Icon" + (i + 1));
        }
    }
Ejemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     Mytrans = GetComponent<Transform>();
        InitFacing = Mytrans.forward.normalized;
        Reset = true;
        RotateSpeed = 0.8f;
 }
Ejemplo n.º 19
0
    public static float CrossToTarget(Transform thisXform, Vector3 targetPos)
	{
		Vector3 nominalPos = thisXform.position;
		Vector3 DirToTarget = (targetPos - nominalPos).normalized;
		Vector3 ForwardDir = thisXform.forward.normalized;
		return Vector3.Cross(ForwardDir, DirToTarget).y;
	}
Ejemplo n.º 20
0
    //Sets up the outer walls and floor (background) of the game board.
    void BoardSetup()
    {
        //Instantiate Board and set boardHolder to its transform.
        boardHolder = new GameObject ("Board").transform;

        //Loop along x axis, starting from -1 (to fill corner) with floor or outerwall edge tiles.
        for(int x = -1; x < columns + 1; x++) {
            //Loop along y axis, starting from -1 to place floor or outerwall tiles.
            for(int y = -1; y < rows + 1; y++) {
                //Choose a random tile from our array of floor tile prefabs and prepare to instantiate it.
                GameObject toInstantiate = floorTiles[Random.Range (0,floorTiles.Length)];

                //Check if we current position is at board edge, if so choose a random outer wall prefab from our array of outer wall tiles.
                if(x == -1 || x == columns || y == -1 || y == rows)
                    toInstantiate = outerWallTiles [Random.Range (0, outerWallTiles.Length)];

                //Instantiate the GameObject instance using the prefab chosen for toInstantiate at the Vector3 corresponding to current grid position in loop, cast it to GameObject.
                GameObject instance =
                    Instantiate (toInstantiate, new Vector3 (x, y, 0f), Quaternion.identity) as GameObject;

                //Set the parent of our newly instantiated object instance to boardHolder, this is just organizational to avoid cluttering hierarchy.
                instance.transform.SetParent (boardHolder);
            }
        }
    }
Ejemplo n.º 21
0
    public void SetTarget(GameObject NewTarget)
    {
        Target = NewTarget;
        Reset = false;

        EnemyTransform = Target.GetComponent<Transform>();
    }
Ejemplo n.º 22
0
 // Use this for initialization
 void Start()
 {
     m_eState = State.A2B;
     transform.position = m_tPatrolPointA.position;
     m_tOrigin = m_tPatrolPointA;
     m_tTarget = m_tPatrolPointB;
 }
    // Use this for initialization
    void Start()
    {
        //make a reference with the transform component
        this._transform = gameObject.GetComponent<Transform>();
        this.Reset();

    }
Ejemplo n.º 24
0
	/// <summary>
	/// tries to award an item to a recipient by transform, item type
	/// and amount
	/// </summary>
	public static bool TryGiveItem(Transform recipient, vp_ItemType itemType, int amount)
	{

		if (recipient == null)
		{
			Debug.LogError("Error (" + Instance + ") Recipient was null.");
			return false;
		}

		vp_Inventory inventory;
		if (!m_RecipientInventories.TryGetValue(recipient, out inventory))
		{
			inventory = vp_TargetEventReturn<vp_Inventory>.SendUpwards(recipient, "GetInventory");
			m_RecipientInventories.Add(recipient, inventory);
		}

		if (inventory == null)
		{
			Debug.LogError("Error (" + Instance + ") Failed to find an enabled inventory on '" + recipient + "'.");
			return false;
		}

		if (TryMatchExistingItem(inventory, recipient, itemType, amount))
			return true;

		return TryGiveItemAsNew(recipient, itemType, amount);
	
	}
Ejemplo n.º 25
0
    /// <summary>
    /// Calculate the combined bounds of all widgets attached to the specified game object or its children (in world space).
    /// </summary>
    public static Bounds CalculateAbsoluteWidgetBounds(Transform trans)
    {
        UIWidget[] widgets = trans.GetComponentsInChildren<UIWidget>() as UIWidget[];

        Bounds b = new Bounds(trans.transform.position, Vector3.zero);
        bool first = true;

        foreach (UIWidget w in widgets)
        {
            Vector2 size = w.relativeSize;
            Vector2 offset = w.pivotOffset;
            float x = (offset.x + 0.5f) * size.x;
            float y = (offset.y - 0.5f) * size.y;
            size *= 0.5f;

            Transform wt = w.cachedTransform;
            Vector3 v0 = wt.TransformPoint(new Vector3(x - size.x, y - size.y, 0f));

            // 'Bounds' can never start off with nothing, apparently, and including the origin point is wrong.
            if (first)
            {
                first = false;
                b = new Bounds(v0, Vector3.zero);
            }
            else
            {
                b.Encapsulate(v0);
            }

            b.Encapsulate(wt.TransformPoint(new Vector3(x - size.x, y + size.y, 0f)));
            b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y - size.y, 0f)));
            b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y + size.y, 0f)));
        }
        return b;
    }
Ejemplo n.º 26
0
	void Start(){
		player = GameObject.FindGameObjectWithTag ("Player").transform;
		playerAtkAndDamge = player.GetComponent<PlayerATKAndDamage> ();
		cc = this.GetComponent<CharacterController> ();
		animator = this.GetComponent<Animator> ();
		attackTimer = attackTime;
	}
Ejemplo n.º 27
0
 public StateAgro(NavMeshAgent _agent, Vector3 _point, Transform _transform, ref StateSet _set)
 {
     set = _set;
     transform = _transform;
     agent = _agent;
     point = _point;
 }
Ejemplo n.º 28
0
	public override void Shot (Vector3 shotOrigin, GameObject target, Transform cannonTransform)
	{
		//if(WeaponReady)
		{
			WeaponReady = false;
			
			Vector3 shotDirection = cannonTransform.forward;
			
			// Note: In a real project, you must not instante many objects a runtime, instead, you may consider creating a shoot pool.
			Rigidbody newBullet = Instantiate(bullet,shotOrigin,cannonTransform.rotation) as Rigidbody;
			
			newBullet.AddForce(shotForce*shotDirection);
			
			if(shotSound != null && shotAudioSource != null)
				shotAudioSource.PlayOneShot(shotSound);
			
			if(weaponParticleSystem != null)
				weaponParticleSystem.Play();
			
			StartCoroutine(LightFlash());
			
			// Reset timmer
			timeCounter = 0f;
		}
	}
Ejemplo n.º 29
0
	/// <summary>
	/// Cache the transform.
	/// </summary>

	protected virtual void Start ()
	{
		mTrans = transform;
		mCollider = GetComponent<Collider>();
		mButton = GetComponent<UIButton>();
		mDragScrollView = GetComponent<UIDragScrollView>();
	}
	// Reparents to a new object and deactivates that object (this allows
	// us to call SetActive in OnDeviceConnected independently.
	private void HideObject(Transform t, string name)
	{
		var hidden = new GameObject(name).transform;
		hidden.parent = t.parent;
		t.parent = hidden;
		hidden.gameObject.SetActive(false);
	}
Ejemplo n.º 31
0
 public void changeCharacter(GameObject newCharacter)
 {
     m_Character = newCharacter.GetComponent <Transform>();
 }
 void Awake()
 {
     flor_tr = transform.GetChild(0);
 }
Ejemplo n.º 33
0
 void Start()
 {
     facingRight = false;
     player = GameObject.FindGameObjectWithTag(Tags.PLAYER).GetComponent<Transform>();
     rb = GetComponent<Rigidbody2D>();
 }
Ejemplo n.º 34
0
 void Awake()
 {
     trans = transform;
 }
Ejemplo n.º 35
0
 protected override void BindView()
 {
     group = transform.Find("Scroll View").Find("Viewport").Find("SchoolInvitations");
     selectToogle = transform.Find("SelectToogle").GetComponent<ToggleGroup>();
     groupTrans = group.GetComponent<RectTransform>();
 }
Ejemplo n.º 36
0
	private void Start()
	{
		start = transform.GetChild(0);
		end = transform.GetChild(1);
	}
 /// <summary>
 /// The SetGrabbedSnapHandle method is used to set the snap handle of the object at runtime.
 /// </summary>
 /// <param name="handle">A transform of an object to use for the snap handle when the object is grabbed.</param>
 public void SetGrabbedSnapHandle(Transform handle)
 {
     grabbedSnapHandle = handle;
 }
Ejemplo n.º 38
0
 private void Awake()
 {
     playerInput = FindObjectOfType <PlayerInput>();
     cam         = GetComponent <Camera>();
     player      = GameObject.FindWithTag("Player").transform;
 }
Ejemplo n.º 39
0
	// Use this for initialization
	void Awake() {
        height = 2*Camera.main.orthographicSize;
        width = height * Camera.main.aspect;
        screenwidth = width;
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
	}
Ejemplo n.º 40
0
 public Arma(GameObject arma, GameObject projetilPrefab)
 {
     _projetilPrefabObjet = projetilPrefab;
     _armaTransform       = arma.GetComponent <Transform>();
     _projetilRef         = arma.transform.GetChild(0);
 }
Ejemplo n.º 41
0
	void Start () {
		thisTransform = transform ;
		posX = transform.localPosition.x ;
	}
Ejemplo n.º 42
0
 private void Awake()
 {
     rig = GetComponent <Rigidbody>();
     cam = transform.GetChild(0);
 }
Ejemplo n.º 43
0
 private void Start()
 {
     temp = GameObject.FindGameObjectsWithTag("Room")[0].GetComponent<RoomTemplate>();
     Parent_Room_Class = temp.transform;
     Invoke("Spawn", 0.1f);
 }
Ejemplo n.º 44
0
 public LogoBrain(GameObject owner) : base(owner)
 {
     _transform       = owner.Components.Get <Transform>() ?? throw new ArgumentOutOfRangeException(nameof(Transform));
     _renderComponent = owner.Components.Get <SpriteRenderComponent>() ?? throw new ArgumentOutOfRangeException(nameof(SpriteRenderComponent));
 }
Ejemplo n.º 45
0
	void Start ()
    {
        _selfTransform = GetComponent<Transform>();
        _startPosition = GetComponentInParent<Transform>().position;
	}
Ejemplo n.º 46
0
	// Use this for initialization
	void Start () {
		player = GameObject.Find("Player").transform;
	}
Ejemplo n.º 47
0
 private void Start()
 {
     cameraT = Camera.main.transform;
     body    = GetComponent <GravityBody>();
 }
Ejemplo n.º 48
0
    private void autoBind(CustomBehaviour customBehaviour)
    {
        _autoBindFields.Clear();

        FieldInfo[] fields = customBehaviour.GetType().GetFields();
        foreach (FieldInfo field in fields)
        {
            object[] attributes = field.GetCustomAttributes(true);
            foreach (object attr in attributes)
            {
                if (attr is BindAttribute)
                {
                    string bindName = ((BindAttribute)attr).getBindName();
                    if (string.IsNullOrEmpty(bindName))
                    {
                        continue;
                    }

                    Transform bindTr = null;
                    if (bindName.Equals("."))
                    {
                        bindTr = customBehaviour.transform;
                    }
                    else
                    {
                        bindTr = customBehaviour.transform.Find(bindName);
                    }

                    if (bindTr == null)
                    {
                        Debug.LogError("cannot find object:" + bindName);
                        continue;
                    }

                    Type bindType = field.FieldType;
                    if (bindType == typeof(GameObject))
                    {
                        field.SetValue(customBehaviour, bindTr.gameObject);
                        _autoBindFields.Add(field.Name);
                    }
                    else if (bindType.IsSubclassOf(typeof(Component)))
                    {
                        Component c = bindTr.GetComponent(bindType);
                        if (c != null)
                        {
                            field.SetValue(customBehaviour, c);
                            _autoBindFields.Add(field.Name);
                        }
                        else
                        {
                            Debug.LogError("cannot find component " + bindType.Name + " in bindName");
                        }
                    }
                    else
                    {
                        Debug.LogError("not suport bind type: " + bindType.Name);
                    }
                }
            }
        }
    }
Ejemplo n.º 49
0
	void Start () {
		get_transform = this.GetComponent<Transform> ();
	}
Ejemplo n.º 50
0
    private void Awake()
    {
        //Get controllers
        me = this;

        canvasObject  = GameObject.Find("GeneralCanvas");
        canvasManager = canvasObject.GetComponent <CanvasManager>();
        menuInteract  = canvasObject.GetComponent <MenuInteract>();

        playerObject     = GameObject.Find("FirstPersonPlayer");
        playerBody       = playerObject.GetComponent <CharacterController>();
        playerController = playerObject.GetComponent <PlayerController>();
        playerCam        = playerObject.GetComponentInChildren <Camera>();
        playerView       = playerObject.GetComponentInChildren <PlayerView>();
        audioManager     = FindObjectOfType <AudioManager>();
        dialogManager    = FindObjectOfType <DialogManager>();
        slotsController  = FindObjectOfType <SlotsController>();


        canvasManager.gameManager  = me;
        canvasManager.menuInteract = menuInteract;
        menuInteract.canvasManager = canvasManager;

        //Get game objects
        miniMapCam           = GameObject.Find("MinimapCam").GetComponent <Camera>();
        miniMapController    = miniMapCam.GetComponent <MiniMapController>();
        gearsInLevel         = GameObject.Find("GearsInLevel");
        shopObject           = GameObject.Find("Shop");
        initialGearPosition1 = GameObject.Find("InitialGear1").transform.position;
        initialGearPosition2 = GameObject.Find("InitialGear2").transform.position;
        initialGearPosition3 = GameObject.Find("InitialGear3").transform.position;
        gearPosition1        = GameObject.Find("Gear1Position").transform.position;
        gearPosition2        = GameObject.Find("Gear2Position").transform.position;
        gearPosition3        = GameObject.Find("Gear3Position").transform.position;
        gearPosition4        = GameObject.Find("Gear4Position").transform.position;
        bossPandaPosition    = GameObject.Find("BossPandaSpawnPoint").transform.position;
        bossMammothPosition  = GameObject.Find("BossMammothSpawnPoint").transform.position;

        level1 = GameObject.Find("Level1").GetComponent <LevelBuilder>();
        level2 = GameObject.Find("Level2").GetComponent <LevelBuilder>();

        introCinematique = FindObjectOfType <VideoPlayer>();

        gearSlot1 = GameObject.Find("GearSlot1");
        gearSlot2 = GameObject.Find("GearSlot2");
        gearSlot3 = GameObject.Find("GearSlot3");

        //Get HUD
        barArmor  = GameObject.Find("Armor Bar").GetComponent <HUDBar>();
        barHealth = GameObject.Find("Health Bar").GetComponent <HUDBar>();

        textArmor  = GameObject.Find("Current Armor").GetComponent <HUDText>();
        textHealth = GameObject.Find("Current Health").GetComponent <HUDText>();
        textMoney  = GameObject.Find("Current Money").GetComponent <HUDText>();

        weaponHUD     = GameObject.Find("HUDWeapon");
        textMunitions = GameObject.Find("Munitions").GetComponent <HUDText>();
        textCapacity  = GameObject.Find("Capacity").GetComponent <HUDText>();
        weaponHUD.SetActive(false);
        consumableHUD            = GameObject.Find("HUDConsumable");
        textConsumablesRemaining = consumableHUD.GetComponentInChildren <HUDText>();
        consumableHUD.SetActive(false);

        textSlot1 = GameObject.Find("TextSlot 1").GetComponent <HUDText>();
        textSlot2 = GameObject.Find("TextSlot 2").GetComponent <HUDText>();
        textSlot3 = GameObject.Find("TextSlot 3").GetComponent <HUDText>();

        //Get Teleporters

        tpToLevel1FromTuto = GameObject.Find("tpToLevel1FromTuto").transform;
        tpToTutoFromLevel1 = GameObject.Find("tpToTutoFromLevel1").transform;

        tpToLevel1FromArena1 = GameObject.Find("tpToLevel1FromArena1").transform;

        tpToMarketFromArena1 = GameObject.Find("tpToMarketFromArena1").transform;
        tpToMarketFromArena1.gameObject.SetActive(false);
        tpToArena1FromMarket = GameObject.Find("tpToArena1FromMarket").transform;

        tpToLevel2FromMarket = GameObject.Find("tpToLevel2FromMarket").transform;
        tpToMarketFromLevel2 = GameObject.Find("tpToMarketFromLevel2").transform;

        tpToLevel2FromArena2 = GameObject.Find("tpToLevel2FromArena2").transform;

        introCinematique.Play();

        //Set Layer Masks

        groundMask  = 256;
        enemiesMask = 512;
        playerMask  = 1024;
        gearMask    = 2048;
        tpMask      = 4096;
        npcMask     = 8192;

        playerSpawnPoint = playerController.transform.position;


        InitializePlayer();
        dialogManager.gameManager   = me;
        playerView.gameManager      = me;
        miniMapController.player    = playerBody.transform;
        slotsController.gameManager = me;
        gearsInGame = new List <GearController>();
        enemies     = new List <EnemyStats>();
        npcInGame   = new List <NPC>();



        EnemyStats[] initialEnemies = FindObjectsOfType <EnemyStats>();

        foreach (EnemyStats enemy in initialEnemies)
        {
            InitializeEnemy(enemy);
        }

        NPC[] initialNPCs = FindObjectsOfType <NPC>();

        foreach (NPC npc in initialNPCs)
        {
            InitializeNPC(npc);
        }

        canvasManager.InitiateCanvas(playerController);
        StartCoroutine("CheckIfIntroFinished");
    }
    private void Start()
    {
        finishPoint = GameObject.FindGameObjectWithTag("FinishPointForBar").transform;
        firstDistance = Mathf.Abs(finishPoint.position.z) - Mathf.Abs(playerPoint.position.z);

    } // Start()
Ejemplo n.º 52
0
    /*
    public void ScoreUpdate(string _ScoreInfo, int _Score)
    {
        currentScenarioScore += _Score;
        if (currentScenarioScore < 0)
            currentScenarioScore = 0;

        currentSectionScore += _Score;
        if (currentSectionScore < 0)
            currentScenarioScore = 0;

        theUIManager.CurrentScoreUpdate(currentScenarioScore);
        theUIManager.SpawnScoreNotification(_ScoreInfo, _Score);
    }
    */

    public float GetDistanceOnSpline(Vector3 _StartingPosOnSpline, Vector3 _EndingPosOnSpline, Transform _StartingBenchmarkTransform, Transform _EndingBenchmarkTransform)
    {
        float distance = 0f;

        Transform[] closestPointsToStartingPos = GetClosestEvenPointNearby(_StartingPosOnSpline + _StartingBenchmarkTransform.transform.forward * .1f, .8f);
        Debug.Log("Closest Points to Starting Pos Length: " + closestPointsToStartingPos.Length);

        ///
        GameObject StartingPosGameobjectCheck = GameObject.Find("StartingPosPointNearbyDetection");

        if (StartingPosGameobjectCheck != null)
            Destroy(StartingPosGameobjectCheck.gameObject);

        GameObject startingPosPointNearbyDetection = new GameObject("StartingPosPointNearbyDetection");
        startingPosPointNearbyDetection.AddComponent<Z_TestEverything>();
        startingPosPointNearbyDetection.transform.position = _StartingPosOnSpline + _StartingBenchmarkTransform.transform.forward * .1f;
        ///

        int nextClosestPointIndexToStartingPos = -1;

        if (closestPointsToStartingPos.Length == 1)
        {
            nextClosestPointIndexToStartingPos = evenPoints.IndexOf(closestPointsToStartingPos[0].transform.position);
        }
        else if (closestPointsToStartingPos.Length == 2)
        {
            nextClosestPointIndexToStartingPos = Mathf.Max(evenPoints.IndexOf(closestPointsToStartingPos[0].transform.position), evenPoints.IndexOf(closestPointsToStartingPos[1].transform.position));
        }
        //Debug.Log("Next Closest Point Index to Starting Pos: " + nextClosestPointIndexToStartingPos);

        distance += Vector3.Distance(_StartingPosOnSpline, evenPoints[nextClosestPointIndexToStartingPos]);

        Transform[] closestPointsToEndingPos = GetClosestEvenPointNearby(_EndingPosOnSpline + _EndingBenchmarkTransform.transform.forward * -.1f, .8f);
        Debug.Log("Closest Points to Ending Pos Length: " + closestPointsToEndingPos.Length);

        ///
        GameObject EndingPosGameobjectCheck = GameObject.Find("StartingPosPointNearbyDetection");

        if (EndingPosGameobjectCheck != null)
            Destroy(EndingPosGameobjectCheck.gameObject);

        GameObject endingPosPointNearbyDetection = new GameObject("EndingPosPointNearbyDetection");
        endingPosPointNearbyDetection.AddComponent<Z_TestEverything>();
        endingPosPointNearbyDetection.transform.position = _EndingPosOnSpline + _EndingBenchmarkTransform.transform.forward * -.1f;


        int previousClosestPointIndexToEndingPos = -1;

        if (closestPointsToEndingPos.Length == 1)
        {
            previousClosestPointIndexToEndingPos = evenPoints.IndexOf(closestPointsToEndingPos[0].transform.position);
        }
        else if (closestPointsToEndingPos.Length == 2)
        {
            previousClosestPointIndexToEndingPos = Mathf.Min(evenPoints.IndexOf(closestPointsToEndingPos[0].transform.position), evenPoints.IndexOf(closestPointsToEndingPos[1].transform.position));
        }
        //Debug.Log("Previous Closest Point Index to Ending Pos: " + previousClosestPointIndexToEndingPos);

        for (int i = nextClosestPointIndexToStartingPos; i < evenPoints.Count + 1; i++)
        {
            if (i == previousClosestPointIndexToEndingPos)
            {
                float previousClosestPointToEndingPosToEndingPosDistance = Vector3.Distance(evenPoints[i], _EndingPosOnSpline);
                distance += previousClosestPointToEndingPosToEndingPosDistance;
                break;
            }
            Vector3 nextPoint = evenPoints[i + 1];
            distance += Vector3.Distance(evenPoints[i], nextPoint);
        }
        //Debug.Log("Distance Between " + _StartingPosOnSpline.name + " and " + _EndingPosOnSpline.name + " is " + distance + "m");
        return distance;
    }
Ejemplo n.º 53
0
    void SpawnPlayerTrainSet(StationScene _ThisStation, int _NumberOfCars)
    {
        if (playerTrainBoogies.Count == 0)
        {
            Vector3 boogiesSpawnOnSpline = lineSpline.FindNearestPointTo(_ThisStation.stopPointOnSpline.position, 25000f);

            GameObject imaginaryBoogieSpawnPos = new GameObject("BoogiesSpawnPos");
            imaginaryBoogieSpawnPos.transform.parent = _ThisStation.stopPointOnSpline;
            imaginaryBoogieSpawnPos.transform.position = boogiesSpawnOnSpline;
            imaginaryBoogieSpawnPos.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);

            Vector3 boogiesSpawnPos = imaginaryBoogieSpawnPos.transform.position + imaginaryBoogieSpawnPos.transform.forward * -currentTrainSet.noseToBoogie;

            for (int i = 0; i < _NumberOfCars; i++)
            {
                GameObject spawnedCar = null;
                Car_Rotation_Setter carRotationSetter = null;

                for (int j = 0; j < 2; j++)
                {
                    GameObject spawnedBoogie = Instantiate(currentTrainSet.boogiePrefab, boogiesSpawnPos, _ThisStation.stopPointOnSpline.rotation);
                    Boogie_Spline_Walker spawneBoogieWalker = spawnedBoogie.GetComponent<Boogie_Spline_Walker>();
                    spawneBoogieWalker.pointsArray = evenPoints.ToArray();
                    playerTrainBoogies.Add(spawnedBoogie);

                    Transform[] closestEvenPointsToBoogie = GetClosestEvenPointNearby(spawnedBoogie.transform.position + spawnedBoogie.transform.forward * .1f, .8f);
                    int nextEvenPointIndex = -1;
                    if (closestEvenPointsToBoogie.Length == 1)
                    {
                        nextEvenPointIndex = evenPoints.IndexOf(closestEvenPointsToBoogie[0].position);
                    }
                    else if (closestEvenPointsToBoogie.Length == 2)
                    {
                        nextEvenPointIndex = Mathf.Max(evenPoints.IndexOf(closestEvenPointsToBoogie[0].position), evenPoints.IndexOf(closestEvenPointsToBoogie[1].position));
                    }
                    spawneBoogieWalker.pointIndexTarget = nextEvenPointIndex;

                    if (j == 0)
                    {
                        spawnedCar = Instantiate(currentTrainSet.carPrefab, spawnedBoogie.transform);
                        carRotationSetter = spawnedCar.GetComponent<Car_Rotation_Setter>();
                        carRotationSetter.bases.Add(spawnedBoogie.transform);
                        spawnedCar.transform.localPosition = currentTrainSet.carLocalPosToFrontBoogie;
                        imaginaryBoogieSpawnPos.transform.position = boogiesSpawnPos;
                        imaginaryBoogieSpawnPos.transform.position += imaginaryBoogieSpawnPos.transform.forward * -currentTrainSet.sameCarBoogie;
                        boogiesSpawnPos = imaginaryBoogieSpawnPos.transform.position;

                        if (i == 0)
                        {
                            spawnedCar.gameObject.tag = "Train_Car_Front";
                            carFrontNose = spawnedCar.transform.Find("Nose");
                            firstBoogie = spawnedBoogie.GetComponent<Boogie_Spline_Walker>();
                        }
                        else if (i == numberOfCar - 1)
                        {
                            spawnedCar.gameObject.tag = "Train_Car_Rear";
                        }
                    }
                    else if (j == 1)
                    {
                        carRotationSetter.bases.Add(spawnedBoogie.transform);
                    }
                }
                imaginaryBoogieSpawnPos.transform.position += imaginaryBoogieSpawnPos.transform.forward * -currentTrainSet.otherCarBoogie;
                boogiesSpawnPos = imaginaryBoogieSpawnPos.transform.position;
            }
            Destroy(imaginaryBoogieSpawnPos.gameObject);
            Debug.Log("Player Train Spawned");
        }
    }
Ejemplo n.º 54
0
 private void Awake()
 {
     pos         = transform.GetChild(0).gameObject.transform;
     rigidbody2D = GetComponent <Rigidbody2D>();
 }
Ejemplo n.º 55
0
	GameObject SpawnNpcAmmo(Transform spawnPoint, GameObject ammoPrefabObj)
	{
		return (GameObject)Instantiate(ammoPrefabObj, spawnPoint.position, spawnPoint.rotation);
	}
Ejemplo n.º 56
0
 public PooledObject GetPooledObject(string poolTag, Transform parent=null, bool activate=true)
 {
     ObjectPool pool = _objectPools.GetOrDefault(poolTag);
     return pool?.GetPooledObject(parent, activate);
 }
Ejemplo n.º 57
0
//	public void SetNpcIsDoFire(NpcMark script)
//	{
//		//Debug.Log("SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
//		if (!NpcScript.IsAniMove) {
//			return;
//		}
//
//		if (SpawnPointScript == null) {
//			return;
//		}
//
//		Transform npcPath = SpawnPointScript.NpcPath;
//		Transform markPar = script.transform.parent;
//		if (npcPath != markPar) {
//			return;
//		}
//		//Debug.Log("***********SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
//		NpcScript.SetIsDoFireAnimation(script.IsFireFeiJiNpc);
//		NpcScript.SetFeiJiMarkInfo(script);
//	}

	void Update()
	{
		if (!XkGameCtrl.IsMoveOnPlayerDeath) {
			if (!XkGameCtrl.IsActivePlayerOne && !XkGameCtrl.IsActivePlayerTwo) {
				return;
			}
		}

		if (IsDeathNPC) {
			return;
		}

		if (!IsTeShuFireNpc) {
			return;
		}

		if (TimeTeShuFire.Length < 1) {
			return;
		}

		if (Network.peerType == NetworkPeerType.Server) {
			return;
		}

		if (JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()
		    || GameOverCtrl.IsShowGameOver) {
			return;
		}

		if (!NpcScript.GetIsDoFireAnimation()) {
			return;
		}

		if (XkGameCtrl.CheckNpcIsMoveToCameraBack(transform)) {
			return;
		}

		GameObject obj = null;
		Transform tran = null;
		for (int i = 0; i < TimeTeShuFire.Length; i++) {
			TimeTeShuFire[i] += Time.deltaTime;
			if (TimeTeShuFire[i] >= TimeFireAmmo[i]) {
				TimeTeShuFire[i] = 0f; //fire ammo
//				Debug.Log("teShuFireNpc -> i = "+i);

				if (i < AudioTeShuNpcFire.Length && AudioTeShuNpcFire[i] != null) {
					if (AudioTeShuNpcFire[i].isPlaying) {
						AudioTeShuNpcFire[i].Stop();
					}
					AudioTeShuNpcFire[i].Play();
				}

				//if (AmmoLZPrefabTeShu != null && AmmoLZPrefabTeShu[i] != null && AmmoLZObjTeShu[i] == null) {
				if (AmmoLZPrefabTeShu != null && AmmoLZPrefabTeShu[i] != null) {
					obj = (GameObject)Instantiate(AmmoLZPrefabTeShu[i],
					                              AmmoSpawnTranTeShu[i].position, AmmoSpawnTranTeShu[i].rotation);
					
					tran = obj.transform;
					//AmmoLZObjTeShu[i] = obj;
					XkGameCtrl.CheckObjDestroyThisTimed(obj);
					tran.parent = AmmoSpawnTranTeShu[i];
				}
				
				PlayerAmmoCtrl ammoPlayerScript = AmmoPrefabTeShu[i].GetComponent<PlayerAmmoCtrl>();
				if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest) {
					continue;
				}

				obj = GetNpcAmmoFromList(AmmoSpawnTranTeShu[i], AmmoPrefabTeShu[i]);
				if (obj == null) {
					return;
				}
				tran = obj.transform;
				tran.parent = XkGameCtrl.NpcAmmoArray;

				NpcAmmoCtrl ammoNpcScript = obj.GetComponent<NpcAmmoCtrl>();
				if (ammoNpcScript != null) {
					ammoNpcScript.SetNpcScriptInfo(NpcScript);
					ammoNpcScript.SetIsAimFeiJiPlayer(IsAimFeiJiPlayer);
				}
				else {
					PlayerAmmoCtrl ammoScript = obj.GetComponent<PlayerAmmoCtrl>();
					if (ammoScript != null) {
						Vector3 startPos = tran.position;
						Vector3 firePos = tran.position;
						Vector3 ammoForward = tran.forward;
						firePos = Random.Range(300f, 400f) * ammoForward + startPos;
						float fireDisVal = Vector3.Distance(firePos, startPos);
						RaycastHit hit;
						LayerMask FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
						if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value)) {
							//Debug.Log("npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
							firePos = hit.point;
							XKNpcHealthCtrl healthScript = hit.collider.GetComponent<XKNpcHealthCtrl>();
							if (healthScript != null) {
								healthScript.OnDamageNpc(ammoScript.DamageNpc, PlayerEnum.Null);
							}
							
							BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent<BuJiBaoCtrl>();
							if (buJiBaoScript != null) {
								buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null); //buJiBaoScript
							}
						}
						ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null, AmmoMovePath);
					}
				}

//				if (AmmoLiZiPrefab != null) {
//					obj = (GameObject)Instantiate(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
//					tran = obj.transform;
//					tran.parent = XkGameCtrl.MissionCleanup;
//				}
			}
		}
	}
Ejemplo n.º 58
0
 protected override void Init()
 {
     player        = Player.Instance.transform;
     currentUpdate = DoNothing;
     BeginShadowPlayer();
 }
 protected override void Awake()
 {
     base.Awake();
     originalParent = transform.parent;
 }
Ejemplo n.º 60
0
 // Start is called before the first frame update
 void Start()
 {
     //
     bar = transform.Find("Bar");
     setSize(health);
 }