GetComponent() public method

public GetComponent ( Type type ) : Component
type System.Type
return Component
コード例 #1
1
 void OnGUI()
 {
     GUILayout.Box("Legacy Effect Scale Editor", GUILayout.Width(295));
     EditorGUILayout.Space();
     Effect = (GameObject)EditorGUILayout.ObjectField("Legacy Effect", Effect, typeof(GameObject), true); 
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     Scale = float.Parse(EditorGUILayout.TextField("Scale Change Value", Scale.ToString()));
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     if (GUILayout.Button("Scale Apply", GUILayout.Height(70))) 
     {
         if (Effect.GetComponent<csLegacyEffectChanger>() != null)
             Effect.GetComponent<csLegacyEffectChanger>().LegacyEffectScaleChange(Scale);
         else
         {
             Effect.AddComponent<csLegacyEffectChanger>();
             Effect.GetComponent<csLegacyEffectChanger>().LegacyEffectScaleChange(Scale);
         }
         DestroyImmediate(Effect.GetComponent<csLegacyEffectChanger>());
     }
 }
コード例 #2
1
 private void Move(GameObject prefab)
 {
     //move object upwards over time * speed
     Vector2 pos = prefab.GetComponent<RectTransform>().anchoredPosition;
     pos.y += 1 * speed * Time.deltaTime;
     prefab.GetComponent<RectTransform>().anchoredPosition = pos;
 }
コード例 #3
1
ファイル: AcoesJogadorAlvo.cs プロジェクト: Marcos1994/Luria
 public void OnMouseDown()
 {
     //pego a unidade selecionada atravez do controlador de jogo
     GameObject selecionado = gameObject.transform.parent.parent.parent.GetComponent<ControladorDeJogo>().objetoSelecionado;
     //Se tiver algum objeto selecionado, mando a unidade selecionada se mover para o objeto clicado
     if(selecionado != null)
     {//Se tiver alguma unidade selecionada
         if(tropaJogador == null)
         {//E se nao tiver nem uma unidade nesse alvo (unidade do jogador)
             //Defino que tem uma unidade vindo pra ca
             tropaJogador = selecionado;
             //Se a unidade que esta vindo estiver vindo de um outro alvo, limpo o alvo antigo
             if(tropaJogador.GetComponent<ComportamentoDeUnidade>().alvoAtual != null)
                 tropaJogador.GetComponent<ComportamentoDeUnidade>().alvoAtual.GetComponent<AcoesJogadorAlvo>().tropaJogador = null;
             //Mando a unidade se mover para o alvo atual
             tropaJogador.GetComponent<ComportamentoDeUnidade>().moverSoldados(gameObject);
             //E digo que esse alvo e o novo destino dele
             tropaJogador.GetComponent<ComportamentoDeUnidade>().alvoAtual = gameObject;
             //atualizar as cores do alvo
             atualizarCores();
         }
         else
             gameObject.transform.parent.parent.parent.GetComponent<ControladorDeJogo>().hud.GetComponent<ControladorDeInterface>().escreverMensagem("Nao pode haver dois grupos em um mesmo alvo");
     }
 }
コード例 #4
0
        public void AddInlineGraphicsChild()
        {
            if (m_inlineGraphic != null)
            {
                //Debug.LogWarning("A child Inline Graphics object already exists.");
                return;
            }

            GameObject inlineGraphicObj = new GameObject("Inline Graphic");

            m_inlineGraphic = inlineGraphicObj.AddComponent<InlineGraphic>();

            m_inlineGraphicRectTransform = inlineGraphicObj.GetComponent<RectTransform>();
            m_inlineGraphicCanvasRenderer = inlineGraphicObj.GetComponent<CanvasRenderer>();

            m_inlineGraphicRectTransform.SetParent(transform, false);
            m_inlineGraphicRectTransform.localPosition = Vector3.zero;
            m_inlineGraphicRectTransform.anchoredPosition3D = Vector3.zero;
            m_inlineGraphicRectTransform.sizeDelta = Vector2.zero;
            m_inlineGraphicRectTransform.anchorMin = Vector2.zero;
            m_inlineGraphicRectTransform.anchorMax = Vector2.one;

            m_TextMeshPro = gameObject.GetComponent<TextMeshPro>();
            m_TextMeshProUI = gameObject.GetComponent<TextMeshProUGUI>();
        }
コード例 #5
0
 // Use this for initialization
 void Start () {
     _AmbientMainSource = Instantiate(_audioSourcePrefab, transform.position, Quaternion.identity) as GameObject;
     _AmbientMainSource.transform.parent = this.transform;
     _AmbientMainSource.GetComponent<AudioSource>().clip = _music;
     _AmbientMainSource.GetComponent<AudioSource>().loop = true;
     _AmbientMainSource.GetComponent<AudioSource>().Play();
 }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        timerText = GameObject.Find("dynamic timer text");
        monster = GameObject.Find("Player");
        timer += Time.deltaTime;
        gameOver += Time.deltaTime;

        if (timer > 1.0f)
        {
            transform.Rotate((float)180/levelTime, 0.0f, 0.0f);
            timer = 0.0f;
        }

        if (levelTime - gameOver >= 0)
        {
            timerText.GetComponent<Timer>().timer = levelTime - gameOver;
        }

        if (gameOver > levelTime && GameObject.Find("Plant") != null)
        {
            //gameOverText.active = true;
            nextLevelBut.transform.Translate(1,0,0);
            gameOverText.GetComponent<GUIText>().text = "You Survived The Day Victory Is Yours!";
            monster.GetComponent<AIFollow>().Stop();
            if (monster.GetComponent<AIFollow>().speed <= 0)
            {
                Destroy(monster);
            }
            gameOver = 0.0f;
        }
    }
コード例 #7
0
    public void ProcessClickedCube(GameObject clickedCube, int x, int y)
    {
        print (x + ", " + y);

        if (x == airplane.x && y == airplane.y && airplane.activeAirplane == false) {
            airplane.activeAirplane = true;
            allCubes [8, 0].GetComponent<Renderer> ().material.color = Color.black;
            clickedCube.GetComponent<Renderer> ().material.color = Color.yellow;
            print ("Active Airplane");
        } //activate airplane

        else if (x == airplane.x && y == airplane.y && airplane.activeAirplane) {
            airplane.activeAirplane = false;
            allCubes [8, 0].GetComponent<Renderer> ().material.color = Color.black;
            clickedCube.GetComponent<Renderer> ().material.color = Color.red;
            print ("Inactive airplane");
        }//deactivate airplane

        /*else if (airplane.activeAirplane && (x != airplane.x || y != airplane.y)) {
            allCubes[airplane.x, airplane.y].GetComponent<Renderer>().material.color = Color.white;
            allCubes[8,0].GetComponent<Renderer>().material.color = Color.black;
            allCubes[x,y].GetComponent<Renderer>().material.color = Color.yellow;
            airplane.x = x;
            airplane.y = y;
            print ("Teleport!")
        }*/
    }
コード例 #8
0
 public void SetAttacker(GameObject g)
 {
     attacker = g;
     if (attacker.gameObject.tag == "Player")
     {
         direction = attacker.GetComponent<CharacterMovementScript>().Direction;
         aimMode = attacker.GetComponent<CharacterMovementScript>().AimMode;
         if (aimMode)
         {
             testIKScript = GameObject.FindGameObjectWithTag("Player").GetComponent<TestIKScript>();
             position = testIKScript.lookObj.position;
             this.transform.LookAt(position);
         }
         else
         {
             //Debug.Log("Tossed Grenade");
             position = GameObject.FindGameObjectWithTag("LookAtObj").transform.position;
             this.transform.LookAt(position);
         }
     }
     else if (attacker.GetComponent<GuardController>())
     {
         if (attacker.GetComponent<GuardController>().movingSpeed < 0)
             direction = true;
         else
             direction = false;
     }
     else
     {
         position = GameObject.FindGameObjectWithTag("Player").transform.position;
         this.transform.LookAt(position);
     }
 }
コード例 #9
0
ファイル: NETJKctrl.cs プロジェクト: 1101137226/mao345
	// Use this for initialization
	void Start () {
	string  a=GameObject.Find("UIRoot").GetComponent<NETSAVE>().thisname;
		inin = false;
		inin2 = true;
		inin3 = true;
		if (a != master) {

			target=GameObject.Find(a).gameObject;

			inin=true;
			bool targetjk=target.GetComponent<NETBS>().jk;

			if(targetjk!=jk)
			{
				GameObject.Find(a).GetComponent<NETBS>().CmdJKctrlboom(this.gameObject);
				boomflag=true;
				CmdBoom();
			}

			target.GetComponent<NETBS>().JkCtrled(jk);
			target.GetComponent<NETBS>().isjk=true;


				}

		this.transform.parent = GameObject.Find ("other").transform;

	}
コード例 #10
0
ファイル: DeathZone.cs プロジェクト: Joon-min/Serious_game
    IEnumerator PlayerDeath(GameObject temp)
    {
        //player.GetComponent<PlatformerAnimation>().PlayerDied();
        temp = this.player;

        if(temp.name=="Player"){
        temp.GetComponent<PlayerController>().RemoveControl();
        AudioSource.PlayClipAtPoint(deathSound, temp.transform.position);
        yield return new WaitForSeconds(2.0f);
        temp.GetComponent<PlayerPhysics>().Reset();
        //player.GetComponent<PlatformerAnimation>().PlayerLives();

        temp.GetComponent<PlayerController>().GiveControl();
        }

        else {
            BoxController control = temp.GetComponent<BoxController>();

            if(control.velCheck()){
            AudioSource.PlayClipAtPoint(boxPop, temp.transform.position);
            //yield return new WaitForSeconds(2.0f);
                temp.GetComponent<PlayerPhysics>().Reset();
            }
        }
    }
コード例 #11
0
ファイル: Bone.cs プロジェクト: chimchim/Chilenska
    public static Bone Create() {
        GameObject b = new GameObject("Bone");
        Undo.RegisterCreatedObjectUndo(b, "Add child bone");
        b.AddComponent<Bone>();

        if (Selection.activeGameObject != null) {
            GameObject sel = Selection.activeGameObject;
            b.transform.parent = sel.transform;

            if (sel.GetComponent<Bone>() != null) {
                Bone p = sel.GetComponent<Bone>();
                b.transform.position = p.Head;
                b.transform.localRotation = Quaternion.Euler(0, 0, 0);
            }
        }

        Skeleton skel = b.transform.root.GetComponentInChildren<Skeleton>();

        if (skel != null) {
            Bone[] bones = skel.GetComponentsInChildren<Bone>();
            int index = bones.Max(bn => bn.index) + 1;
            b.GetComponent<Bone>().index = index;
            skel.CalculateWeights();
        }

        Selection.activeGameObject = b;

        return b.GetComponent<Bone>();
    }
コード例 #12
0
    void fire()
    {
        currentAmmo--;

        Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);

        AudioSource.PlayClipAtPoint (sound, transform.position);

        GameObject zombini = GameObject.Find ("Zombini");

        bool  temp = zombini.GetComponent<ZombiniController>().facingRight;

        Vector3 spawnLocation = GameObject.Find("sphere_missile").transform.position;

        missile = ((GameObject)Instantiate (Resources.Load ("prefab_missile"), spawnLocation, transform.rotation));

        Vector3 flip = new Vector3(-4, 4, 1);

        Vector3 temp2 = new Vector3(1,0,2);
        Vector3 temp3 = new Vector3(-1,0,2);

        if(mousePos.x > transform.position.x)
        {
            missile.transform.localScale = flip;
            missile.GetComponent<Missile> ().velocity = temp2;
        }
        else
            missile.GetComponent<Missile> ().velocity = temp3;

        mousePos.z = 1;

        // missile.GetComponent<Missile> ().velocity = (mousePos - transform.position).normalized;

        // missile.GetComponent<Missile> ().velocity = temp2;
    }
コード例 #13
0
ファイル: qd_Mesh.cs プロジェクト: zjucsxxd/UnityRepository
        public static GameObject CreateDecal(Material mat, Rect uvCoords, float scale)
        {
            GameObject decal = new GameObject();
            decal.name = "Decal" + decal.GetInstanceID();

            decal.AddComponent<MeshFilter>().sharedMesh = DecalMesh("DecalMesh" + decal.GetInstanceID(), mat, uvCoords, scale);
            decal.AddComponent<MeshRenderer>().sharedMaterial = mat;

            #if UNITY_5
            decal.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            #else
            decal.GetComponent<MeshRenderer>().castShadows = false;
            #endif

            qd_Decal decalComponent = decal.AddComponent<qd_Decal>();

            decalComponent.SetScale(scale);
            decalComponent.SetTexture( (Texture2D)mat.mainTexture );
            decalComponent.SetUVRect(uvCoords);

            #if DEBUG
            decal.AddComponent<qd_DecalDebug>();
            #endif

            return decal;
        }
コード例 #14
0
 public void Decorate(GameObject go, CustomSceneryV1 customScenery)
 {
     if (go.GetComponent<Deco>() != null)
     {
         go.GetComponent<Deco>().defaultGridSubdivision = customScenery.GridSubdivision;
     }
 }
コード例 #15
0
ファイル: Sounds.cs プロジェクト: alexidr/LD33
    public static void PlaySounds(GameObject obj, AudioClip[] clips)
    {
        if(clips == null || clips.Length == 0) return;

        obj.GetComponent<AudioSource>().clip = clips[Random.Range(0, clips.Length)];
        obj.GetComponent<AudioSource>().Play();
    }
コード例 #16
0
    void Update()
    {
        if (ritualStart)
        {
            GetComponent<EllipsoidParticleEmitter>().emit = true;
            GetComponent<ParticleAnimator>().damping = timeAndDumbing;
            timeAndDumbing += 0.01f;

            if (isTriggered & !isCreated)
            {
                GetComponent<EllipsoidParticleEmitter>().emit = true;
               enemy = Instantiate(enemyPrefab, transform.position, Quaternion.identity) as GameObject;
                monkGroup.GetComponent<InputHandler>().enemy = enemy;
                enemy.GetComponent<Enemy>().canvasPlane = plane;
                enemy.GetComponent<Enemy>().canvasText = text;
                isCreated = true;
                monkGroup.GetComponent<GroupMovement>().StopMovement();
            }

            if (timeAndDumbing >= 1)
            {
                GetComponent<EllipsoidParticleEmitter>().emit = false;
                enemy.GetComponent<EnemyMovement>().StartMovement();
                monkGroup.GetComponent<GroupMovement>().StartMovement();
                monkGroup.GetComponent<GroupMovement>().movementSpeed = 5.0f;
                Destroy(this.gameObject, 2.0f);
            }
        }
    }
コード例 #17
0
ファイル: SceneController.cs プロジェクト: Dotby/ARCocaCola
    public void ShowPart(GameObject _pt)
    {
        foreach(GameObject _obj in _parts){
            _obj.GetComponent<ObjControll>()._info.SetActive(false);
        }

        FsmVariables.GlobalVariables.GameObjectVariables[0] = _pt;

        _pt.GetComponent<ObjControll>()._info.SetActive(true);

        if (_pt.GetComponent<Animator>() != null){
            _pt.GetComponent<Animator>().Play("action");
        }

        _SOUND.StopMusic(true);
        //string sndName = "whisp1";
        switch(_pt.name){
        case "Obj1": _SOUND.Play("whisp1", 0.4f, 1f); rotangle = 335; break;
        case "Obj2": _SOUND.Play("whisp1", 0.4f, 1f); rotangle = 164; break;
        case "Obj3": _SOUND.Play("whisp1", 0.4f, 1f); rotangle = 287; break;
        case "Obj4": _SOUND.Play("swish", 0.4f, 1f); rotangle = 113; break;
        case "Obj5": _SOUND.Play("water", 0.4f, 1f); rotangle = 224; break;
        case "Obj6": _SOUND.Play("swish", 0.4f, 1f);  rotangle = 76; break;
        //case "Obj7": _SOUND.Play("swish", 0.4f, 1f); break;

        default: break;
        }

        PlayMakerGlobals.Instance.Variables.Vector3Variables[0].Value = new Vector3(0, rotangle, 0);
    }
コード例 #18
0
    void AddClusterScripts(GameObject iObject, bool iChildren)
    {
        //MiddleVRTools.Log("AddCluster to " + iObject);
        //print("AddCluster to " + iObject);
        {
            if (iObject.GetComponent<VRShareTransform>() == null)
            {
                VRShareTransform script = iObject.AddComponent<VRShareTransform>() as VRShareTransform;
                script.Start();
            }

            if (iObject.GetComponent<VRApplySharedTransform>() == null)
            {
                VRApplySharedTransform script = iObject.AddComponent<VRApplySharedTransform>() as VRApplySharedTransform;
                script.Start();
            }
        }

        if( iChildren == true )
        {
            foreach (Transform child in iObject.transform)
            {
                GameObject childObject = child.gameObject;

                //print("Child : " + childObject);
                AddClusterScripts(childObject, true);
            }
        }
    }
コード例 #19
0
    public static IEnumerator PlayGameStartAnimation(GameObject cleaver)
    {
        // Display a random tip
        System.Random tipIndex = new System.Random();
        string tipToShow = SwipeballConstants.UIText.TipText[tipIndex.Next(0, SwipeballConstants.UIText.TipText.Length)];

        GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.Tip).GetComponent<Image>().enabled = true;
        GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.TipText).GetComponent<Text>().enabled = true;
        GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.TipText).GetComponent<Outline>().enabled = true;
        GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.TipText).GetComponent<Text>().text = tipToShow;

        GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.ProfilePicture).GetComponent<Image>().CrossFadeAlpha(0.0f, SwipeballConstants.Effects.GameStartGraphicFadeDuration, false);

        foreach (GameObject textGameObject in GameObject.FindGameObjectsWithTag(SwipeballConstants.GameObjectNames.GameObjectTags.TextTag))
        {
            textGameObject.GetComponent<Text>().CrossFadeAlpha(0.0f, SwipeballConstants.Effects.GameStartGraphicFadeDuration, false);
        }

        // Make the cleaver turn green and rotate faster
        cleaver.GetComponent<Rigidbody2D>().angularVelocity = 20;
        cleaver.GetComponent<Light>().color = SwipeballConstants.Colors.Cleaver.HighPower;

        if(SaveDataHandler.GetLoadedSaveData().soundEnabled && GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.MenuEffects).GetComponent<AudioSource>() != null)
        {
            GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.MenuEffects).GetComponent<AudioSource>().PlayOneShot(GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.MenuEffects).GetComponent<AudioSource>().clip);
        }

        // Provides enough time for the above animation to play
        yield return new WaitForSeconds(SwipeballConstants.Effects.GameStartAnimationDuration);

        GameObject.Find(SwipeballConstants.GameObjectNames.MainMenu.MenuEffects).GetComponent<MainMenuBehaviour>().StartGame();
    }
コード例 #20
0
    void Awake()
    {
        carCamera = GameObject.FindObjectOfType<RCCCarCamera>().gameObject;
        carCamera.GetComponent<Camera>().enabled = false;
        carCamera.GetComponent<AudioListener>().enabled = false;

        GetComponent<RCCCarControllerV2>().runEngineAtAwake = false;
        GetComponent<RCCCarControllerV2>().canControl = false;
        GetComponent<RCCCarControllerV2>().engineRunning = false;

        if(carCamera.GetComponent<RCCCarCamera>())
            carCamera.GetComponent<RCCCarCamera>().enabled = true;

        if(GameObject.FindObjectOfType<RCCDashboardInputs>())
            dashboard = GameObject.FindObjectOfType<RCCDashboardInputs>().gameObject;

        if(!getOutPosition){
            GameObject getOutPos = new GameObject("Get Out Position");
            getOutPos.transform.SetParent(transform);
            getOutPos.transform.localPosition = new Vector3(-3f, 0f, 0f);
            getOutPos.transform.localRotation = Quaternion.identity;
            getOutPosition = getOutPos.transform;
        }

        if(GetComponent<RCCCarCameraConfig>())
            GetComponent<RCCCarCameraConfig>().enabled = false;
    }
コード例 #21
0
    public void selection(GameObject g)
    {
        if ((srcHex != null && dstHex != null) || (srcHex == null && dstHex == null)) {
            clear();

            srcHex = g;
            srcHexController = srcHex.GetComponent<HexController>();
            srcSelected = true;

            srcHexController.setSelected(true);
        }
        else if (srcHex != null && dstHex == null) {
            dstHex = g;
            dstHexController = dstHex.GetComponent<HexController>();
            dstSelected = true;

            //Debug.Log (src + " - " + dst);

            // action here!
            Coordinate src = new Coordinate(srcHex.GetComponent<ObjectInfo>().line,srcHex.GetComponent<ObjectInfo>().column);
            Coordinate dst = new Coordinate(dstHex.GetComponent<ObjectInfo>().line,dstHex.GetComponent<ObjectInfo>().column);

            //clear();

            if ( gameState.moveStone(src,dst,gameState.getTurn()) )
            {
                refresh = true;

            }

        }

        //Debug.Log ( src + " - " + dst );
    }
コード例 #22
0
ファイル: ItemWeapon.cs プロジェクト: rogerdv/keyw
 public override void Use(GameObject owner, GameObject target)
 {
     //TODO: get weapon damages, etc
     //get item parent skill level
     var OwnSc = owner.GetComponent<BaseCharacter> ();
     var TargetSc = target.GetComponent<BaseCharacter> ();
     var ps = OwnSc.GetSkill(ParentSkill);
     /*Debug.Log("Parent skill  is "+ps.Name);
     Debug.Log(ps.baseValue);*/
     //calculate hit roll: determines if target is actually hit or evades attack
     int AttackRoll = ps + OwnSc.GetAttribute( (int)Attributes.Str) + OwnSc.GetAttribute((int)Attributes.Dext);
     int DodgeRoll = TargetSc.GetSkill("dodge") + TargetSc.GetAttribute((int)Attributes.Dext);
     int roll = Random.Range (0, AttackRoll + DodgeRoll + 1);
     if (roll > AttackRoll) {
         //Debug.Log("Attack missed!!");
         GameObject.Find("MessageBox").GetComponent<MsgList>().SetText(OwnSc.Name+" hits the air causing a lot of damege to nobody");
     }
     ///weapon does damage: get all damage properties
     foreach (Property p in props) {
         if (p.type=="damage") {
             Debug.Log("Dmg type: "+p.name);
             Debug.Log("Dmg value: "+p.value);
             float dmg = p.value+OwnSc.GetAttribute((int)Attributes.Str)*ps;
             Debug.Log("Effective damage is "+dmg);
             target.GetComponent<BaseCharacter> ().HitPoints [0]-= dmg;
             var bar = GameObject.Find("blood-bar").GetComponent<Image>();
             float percent = TargetSc.HitPoints [0]/TargetSc.HitPoints [1];
             bar.transform.localScale = new Vector3(percent, 1.0f,1.0f);
             //Debug.Log("Dmg value: "+p.value);
             GameObject.Find("MessageBox").GetComponent<MsgList>().SetText(OwnSc.Name+" hits "+TargetSc.Name+" inflicting "+dmg.ToString() +" damage");
         }
     }
 }
コード例 #23
0
ファイル: spout.cs プロジェクト: crazymeeshu/scriptcaster
 // Use this for initialization
 void Start()
 {
     rend = GetComponent<Renderer>();
     pl = GameObject.FindGameObjectWithTag("Player");
     Physics2D.IgnoreCollision(GetComponent<Collider2D>(), pl.GetComponent<Collider2D>());
     Physics2D.IgnoreCollision(GetComponent<Collider2D>(), pl.GetComponent<CircleCollider2D>());
 }
コード例 #24
0
 void Start()
 {
     levelClock = GameObject.Find("gameBase").GetComponent<levelClock>();
     spaceship = GameObject.Find("spaceship");
     rb = spaceship.GetComponent<Rigidbody2D>();
     body = spaceship.GetComponent<Transform>();
 }
コード例 #25
0
        private static EffectStop respawnCharacter(GameObject character)
        {
            return () =>
            {
                var manager = GameObject.Find("GameManager").GetComponent<GameManager>();
                var combatData = character.GetComponent<Combat>();
                var characterData = character.GetComponent<Character>();

                // Consider character to be alive
                combatData.dead = false;
                combatData.selectable = true;

                // Restore health
                combatData.health = combatData.maxHealth;
                combatData.mana = combatData.maxMana();

                // Move Character to correct position
                var spawn = character.tag == "TeamA" ?
                        manager.bluespawn[UnityEngine.Random.Range(0, manager.bluespawn.Length)] :
                        manager.redspawn[UnityEngine.Random.Range(0, manager.redspawn.Length)];
                character.transform.position = spawn.transform.position;

                // Set animation state to alive
                characterData.setAnimation_State(characterData.dead_State, false);

                // Enable movement
                character.GetComponent<NavMeshAgent>().enabled = true;
                character.GetComponent<Rigidbody>().useGravity = true;
            };
        }
コード例 #26
0
 void Fire()
 {
     // 프리팹 동적 생성
     target_projectile = (GameObject)Instantiate(projectile, new Vector3(firePos.x,firePos.y), fireAngle);
     target_projectile.GetComponent<BazookaCtrl>().globalId = GetComponentInParent<NetPlayerCtrl>().globalId;
     target_projectile.GetComponent<BazookaCtrl>().shotPower = fireForce;
 }
コード例 #27
0
 public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
 {
     if (go.GetComponent<Deco>() != null && _grid)
     {
         go.GetComponent<Deco>().buildOnGrid = _grid;
     }
 }
コード例 #28
0
ファイル: MOrbit.cs プロジェクト: mobeid/NP_SIMULATOR
    public void NewTarget(GameObject targ)
    {
        if ( target != targ )
        {
            target = targ;
            t = 0.0f;

            if ( target )
            {
                filter = (MeshFilter)target.GetComponent(typeof(MeshFilter));

                if ( filter != null )
                    center = filter.mesh.bounds.center;
                else
                {
                    render = (MeshRenderer)target.GetComponent(typeof(MeshRenderer));

                    if ( render != null )
                        center = render.bounds.center;
                    else
                    {
                        srender = (SkinnedMeshRenderer)target.GetComponent(typeof(SkinnedMeshRenderer));

                        if ( srender != null )
                            center = srender.bounds.center;
                    }
                }
            }
        }
    }
コード例 #29
0
ファイル: ProceduralBuild.cs プロジェクト: ramichanu/GotoWork
    void addNpcAndAssignHome(GameObject room)
    {
        if(this.npcCount <= this.npcCountMax){
            UnityEngine.Object npcObject = Resources.Load (Utils.PREFAB_CHARACTER_FOLDER + "npc");
            GameObject sofa = null;
            foreach (GameObject roomItemIn in Utils.getChildrenWithTag(room, "object")){

                if(roomItemIn.name == "sofa")
                {
                    sofa = roomItemIn;
                }

            }

            if(sofa != null)
            {
                newNpc = Instantiate(npcObject, transform.position= sofa.transform.position, transform.rotation) as GameObject;
                newNpc.name = "npc" + this.npcCount;
                newNpc.GetComponent<characterValues>().currentRoom = room;
                newNpc.transform.parent = room.transform;
                newNpc.renderer.sortingOrder = 1;
                newNpc.GetComponent<characterValues>().home = room.transform.parent.gameObject;
                newNpc.GetComponent<characterValues>().homeCheckPoint = sofa;
                this.npcCount++;

            }

        }
    }
コード例 #30
0
ファイル: ETCMenu.cs プロジェクト: gww2/EvilTiles
	static void  AddJoystick(){
	
		ETCInput.instance.Create();
		GameObject canvas = SetupUI();

		Object[] sprites = Resources.LoadAll("ETCDefaultSprite");

		GameObject joystick = new GameObject("New Joystick", typeof(ETCJoystick),typeof(RectTransform), typeof( CanvasGroup), typeof(Image) );
		joystick.transform.SetParent( canvas.transform,false);

	
		joystick.GetComponent<Image>().preserveAspect = true;
		joystick.GetComponent<Image>().sprite = GetSpriteByName("ETCArea",sprites);
		joystick.GetComponent<Image>().rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,130);
		joystick.GetComponent<Image>().rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,130);
		joystick.GetComponent<CanvasGroup>().hideFlags = HideFlags.HideInInspector;
		joystick.GetComponent<CanvasRenderer>().hideFlags = HideFlags.HideInInspector;


		GameObject thumb = new GameObject("Thumb",typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));
		thumb.transform.SetParent(joystick.transform,false);
		thumb.GetComponent<Image>().preserveAspect = true;
		thumb.GetComponent<Image>().sprite = GetSpriteByName("ETCThumb",sprites);
		thumb.GetComponent<Image>().rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,80);
		thumb.GetComponent<Image>().rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,80);

		joystick.GetComponent<ETCJoystick>().thumb = thumb.transform as RectTransform;



		Selection.activeGameObject = joystick;
	}
コード例 #31
0
 void SyncEventListeners( )
 {
     if (null == event_UnityEngine_GameObject_Instance_0 || false == m_RegisteredForEvents)
     {
         event_UnityEngine_GameObject_Instance_0 = uScript_MasterComponent.LatestMaster;
         if (null != event_UnityEngine_GameObject_Instance_0)
         {
             {
                 uScript_Update component = event_UnityEngine_GameObject_Instance_0.GetComponent <uScript_Update>();
                 if (null == component)
                 {
                     component = event_UnityEngine_GameObject_Instance_0.AddComponent <uScript_Update>();
                 }
                 if (null != component)
                 {
                     component.OnUpdate      += Instance_OnUpdate_0;
                     component.OnLateUpdate  += Instance_OnLateUpdate_0;
                     component.OnFixedUpdate += Instance_OnFixedUpdate_0;
                 }
             }
         }
     }
     if (null == event_UnityEngine_GameObject_Instance_3 || false == m_RegisteredForEvents)
     {
         event_UnityEngine_GameObject_Instance_3 = GameObject.Find("NewSlowZone") as UnityEngine.GameObject;
         if (null != event_UnityEngine_GameObject_Instance_3)
         {
             {
                 uScript_Trigger component = event_UnityEngine_GameObject_Instance_3.GetComponent <uScript_Trigger>();
                 if (null == component)
                 {
                     component = event_UnityEngine_GameObject_Instance_3.AddComponent <uScript_Trigger>();
                 }
                 if (null != component)
                 {
                     component.OnEnterTrigger     += Instance_OnEnterTrigger_3;
                     component.OnExitTrigger      += Instance_OnExitTrigger_3;
                     component.WhileInsideTrigger += Instance_WhileInsideTrigger_3;
                 }
             }
         }
     }
 }
コード例 #32
0
    public void createPlayer()
    {
        if (player != null)
        {
            if (terrain != null)
            {
                player.GetComponent <GameEntity>().entityEnable();
            }
            return;
        }

        if (KBEngineApp.app.entity_type != "Avatar")
        {
            return;
        }

        KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player();
        if (avatar == null)
        {
            Debug.Log("wait create(palyer)!");
            return;
        }

        float y = avatar.position.y;

        if (avatar.isOnGround)
        {
            y = 1.3f;
        }

        player = Instantiate(avatarPerfab, new Vector3(avatar.position.x, y, avatar.position.z),
                             Quaternion.Euler(new Vector3(avatar.direction.y, avatar.direction.z, avatar.direction.x))) as UnityEngine.GameObject;

        player.GetComponent <GameEntity>().entityDisable();
        avatar.renderObj = player;
        ((UnityEngine.GameObject)avatar.renderObj).GetComponent <GameEntity>().isPlayer = true;

        // 有必要设置一下,由于该接口由Update异步调用,有可能set_position等初始化信息已经先触发了
        // 那么如果不设置renderObj的位置和方向将为0,人物会陷入地下
        set_position(avatar);
        set_direction(avatar);
        set_entityName(avatar, avatar.name);
    }
コード例 #33
0
ファイル: UI_Game.cs プロジェクト: behiever/kbengineTestGame
    // Use this for initialization
    void Start()
    {
        text_content = tran_text.GetComponent <Text>();

        KBEngine.Event.registerOut("ReceiveChatMessage", this, "ReceiveChatMessage");

        //inventory
        UnityEngine.GameObject canvas = UnityEngine.GameObject.FindGameObjectWithTag("Canvas");
        if (canvas.transform.Find("Panel - Inventory(Clone)") != null)
        {
            inventory = canvas.transform.Find("Panel - Inventory(Clone)").gameObject;
        }
        if (canvas.transform.Find("Panel - EquipmentSystem(Clone)") != null)
        {
            characterSystem = canvas.transform.Find("Panel - EquipmentSystem(Clone)").gameObject;
        }
        if (canvas.transform.Find("Panel - State") != null)
        {
            statePanel = canvas.transform.Find("Panel - State").gameObject;
        }

        if (UnityEngine.GameObject.FindGameObjectWithTag("Tooltip") != null)
        {
            toolTip = UnityEngine.GameObject.FindGameObjectWithTag("Tooltip").GetComponent <Tooltip>();
        }
        if (inventory != null)
        {
            mainInventory = inventory.GetComponent <Inventory>();
        }
        if (characterSystem != null)
        {
            characterSystemInventory = characterSystem.GetComponent <Inventory>();
        }
        if (craftSystem != null)
        {
            craftSystemInventory = craftSystem.GetComponent <Inventory>();
        }
        if (statePanel != null)
        {
            avatarState = statePanel.GetComponent <UI_AvatarState>();
        }
    }
コード例 #34
0
        public UnityEngine.GameObject GetGameObject(OutputSocket ouputSocket, Request request)
        {
            if (!_initialLoadingDone)
            {
                LoadGameObject(_objectIdentifier, false);
                _initialLoadingDone = true;
            }

            List <UnityEngine.Vector3> position = AbstractVector3Node.GetInputVector3List(_inputSocketPosition, request);

            if (position != null && position.Count > 0 && _gameObject != null)
            {
                _gameObject.transform.position = position[0];
            }

            UnityEngine.Material material = AbstractMaterialNode.GetInputMaterial(_inputSocketMaterial, request);
            if (_gameObject != null && material != null)
            {
                Renderer renderer = _gameObject.GetComponent <Renderer>();
                if (renderer == null)
                {
                    renderer = _gameObject.AddComponent <MeshRenderer>();
                }
                renderer.material = material;
            }

            List <UnityEngine.Vector3> scale = AbstractVector3Node.GetInputVector3List(_inputSocketScale, request);

            if (scale != null && scale.Count > 0 && _gameObject != null)
            {
                _gameObject.transform.localScale = scale[0];
            }

            List <UnityEngine.Vector3> rotation = AbstractVector3Node.GetInputVector3List(_inputSocketRotation, request);

            if (rotation != null && rotation.Count > 0 && _gameObject != null)
            {
                _gameObject.transform.localRotation = Quaternion.FromToRotation(UnityEngine.Vector3.up, rotation[0]);
            }

            return(_gameObject);
        }
コード例 #35
0
ファイル: RecordPvP.cs プロジェクト: Klanly/UnityClient
 // 返回记录信息
 void ClickItemHandler(UnityEngine.GameObject go)
 {
     try
     {
         //LogicSystem.EventChannelForGfx.Publish("click_record_item", "record", recordDic[go]);
         UnityEngine.GameObject rd = UIManager.Instance.GetWindowGoByName("PPVPRecordData");
         if (rd != null)
         {
             UIRecordData uird = rd.GetComponent <UIRecordData>();
             if (uird != null)
             {
                 uird.ShowRecord(recordDic[go]);
             }
         }
     }
     catch (Exception ex)
     {
         ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
コード例 #36
0
    public void create()
    {
        // 设置默认的模型
        gameObject      = (UnityEngine.GameObject)UnityEngine.GameObject.Instantiate(loader.inst.defaultEntityAsset, position, Quaternion.Euler(eulerAngles));
        gameObject.name = name;
        gameObject.transform.localScale = scale;

        if (loader.inst.entityHudInfosAsset != null)
        {
            hud_infosObj      = (UnityEngine.GameObject)UnityEngine.GameObject.Instantiate(loader.inst.entityHudInfosAsset);
            hud_infosObj.name = "hud_infos";
            hudinfos          = hud_infosObj.GetComponent <Hud_Infos>();
            hudinfos.seo      = this;
            attachHeadInfo();
        }
        else
        {
            Common.WARNING_MSG("SceneEntityObject::Start: not found entityHudInfosAsset!");
        }
    }
コード例 #37
0
        // TODO: Very wrong error messages when creating entity with empty ComponentType array?
        public static Entity AddToEntityManager(EntityManager entityManager, GameObject gameObject)
        {
            var goe = gameObject.GetComponent <GameObjectEntity>();

            if (goe == null)
            {
                goe = gameObject.AddComponent <GameObjectEntity>();
            }
            else if (goe.Entity != Entity.Null)
            {
                return(goe.Entity);
            }

            ComponentType[] types;
            Component[]     components;
            GetComponents(gameObject, true, out types, out components);

            EntityArchetype archetype;

            try
            {
                archetype = entityManager.CreateArchetype(types);
            }
            catch (Exception e)
            {
                for (int i = 0; i < types.Length; ++i)
                {
                    if (Array.IndexOf(types, types[i]) != i)
                    {
                        Debug.LogWarning($"GameObject '{gameObject}' has multiple {types[i]} components and cannot be converted, skipping.");
                        return(Entity.Null);
                    }
                }

                throw e;
            }

            goe.m_Entity = CreateEntity(entityManager, archetype, components, types);

            return(goe.m_Entity);
        }
コード例 #38
0
    public void createPlayer()
    {
        if (player != null)
        {
            player.GetComponent <GameEntity>().entityEnable();
            return;
        }

        if (KBEngineApp.app.entity_type != "Avatar")
        {
            return;
        }

        KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player();
        if (avatar == null)
        {
            Debug.Log("wait create(palyer)!");
            return;
        }

        // 玩家默认在第0层,越小的应该越在下一层, 大的覆盖小的
        float layer = 0.0f;

        player = Instantiate(avatarPerfab, new Vector3(avatar.position.x, avatar.position.z, layer),
                             Quaternion.Euler(new Vector3(avatar.direction.y, avatar.direction.z, avatar.direction.x))) as UnityEngine.GameObject;

        GameEntity entity = player.GetComponent <GameEntity>();

        entity.entityDisable();
        avatar.renderObj = player;
        entity.isAvatar  = true;
        entity.isPlayer  = true;

        // 有必要设置一下,由于该接口由Update异步调用,有可能set_position等初始化信息已经先触发了
        // 那么如果不设置renderObj的位置和方向将为0
        set_position(avatar);
        set_direction(avatar);

        Camera.main.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, -10.0f);
        Camera.main.transform.parent   = player.transform;
    }
コード例 #39
0
        static void GetComponents(GameObject gameObject, bool includeGameObjectComponents, out ComponentType[] types, out Component[] components)
        {
            components = gameObject.GetComponents <Component>();

            var componentCount = 0;

            if (includeGameObjectComponents)
            {
                var gameObjectEntityComponent = gameObject.GetComponent <GameObjectEntity>();
                componentCount = gameObjectEntityComponent == null ? components.Length : components.Length - 1;
            }
            else
            {
                for (var i = 0; i != components.Length; i++)
                {
                    if (components[i] is ComponentDataWrapperBase)
                    {
                        componentCount++;
                    }
                }
            }

            types = new ComponentType[componentCount];

            var t = 0;

            for (var i = 0; i != components.Length; i++)
            {
                var com           = components[i];
                var componentData = com as ComponentDataWrapperBase;

                if (componentData != null)
                {
                    types[t++] = componentData.GetComponentType();
                }
                else if (includeGameObjectComponents && !(com is GameObjectEntity))
                {
                    types[t++] = com.GetType();
                }
            }
        }
コード例 #40
0
    private void InitVictoryPanel(int maxHit, int beHittTimes, int diedTimes, int time)
    {
        try
        {
            if (!WorldSystem.Instance.IsAttemptScene() && !WorldSystem.Instance.IsGoldScene())
            {
                return;
            }
            values[0] = maxHit;
            values[1] = beHittTimes;
            values[2] = diedTimes;
            values[3] = time;

            UnityEngine.GameObject progressgo = UIManager.Instance.GetWindowGoByName("MPVEprogress");
            if (progressgo != null)
            {
                MPVEprogress script = progressgo.GetComponent <MPVEprogress>();
                if (script != null)
                {
                    if (lblBest != null)
                    {
                        int best = script.best > script.current ? script.best : script.current;
                        lblBest.text = best + "/" + script.max;
                    }
                    if (lblCurrent != null)
                    {
                        lblCurrent.text = script.current + "/" + script.max;
                    }
                    if (progressBar != null)
                    {
                        progressBar.value = (float)script.current / script.max;
                    }
                }
            }
            UIManager.Instance.ShowWindowByName("MpveVictoryPanel");
        }
        catch (Exception ex)
        {
            ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace);
        }
    }
コード例 #41
0
ファイル: sth.cs プロジェクト: dixonw1995/PhantomStone
 void SyncEventListeners( )
 {
     if (null == event_UnityEngine_GameObject_Instance_0 || false == m_RegisteredForEvents)
     {
         event_UnityEngine_GameObject_Instance_0 = uScript_MasterComponent.LatestMaster;
         if (null != event_UnityEngine_GameObject_Instance_0)
         {
             {
                 uScript_Input component = event_UnityEngine_GameObject_Instance_0.GetComponent <uScript_Input>();
                 if (null == component)
                 {
                     component = event_UnityEngine_GameObject_Instance_0.AddComponent <uScript_Input>();
                 }
                 if (null != component)
                 {
                     component.KeyEvent += Instance_KeyEvent_0;
                 }
             }
         }
     }
 }
コード例 #42
0
ファイル: PongController.cs プロジェクト: mgovilla/FBLA-QFS
    void FixedUpdate()             //fixed update for physics
    {
        if (!pongManager.gameOver) //As long as game is running
        {
            float xPos = transform.position.x + (Input.GetAxis("Horizontal") * paddleSpeed);
            playerPos          = new Vector3(Mathf.Clamp(xPos, -1.43f, 1.5f), -1.5f, 0f);
            transform.position = playerPos;

            if (newBall) //as long as the newball exists
            {
                Rigidbody ballRigid = newBall.GetComponent <Rigidbody>();
                ballRigid.position = transform.position + new Vector3(0, .3f, 0);
                if (Input.GetKeyDown("space")) //start the game
                {
                    pongManager.isStarted = true;
                    ballRigid.AddForce(0, ballForce, 0);
                    newBall = null;
                }
            }
        }
    }
コード例 #43
0
    public void CameraEnable(object[] args)
    {
        if (null != args[0] && null != args[1])
        {
            string cameraName = args[0] as string;
            bool   isEnable   = (bool)args[1];

            if (null != cameraName)
            {
                UnityEngine.GameObject cameraObj = UnityEngine.GameObject.Find(cameraName);
                if (cameraObj != null)
                {
                    UnityEngine.Camera camera = cameraObj.GetComponent <UnityEngine.Camera>();
                    if (null != camera)
                    {
                        camera.enabled = isEnable;
                    }
                }
            }
        }
    }
コード例 #44
0
ファイル: UIServerSelect.cs プロジェクト: Klanly/UnityClient
    private void OnTweenUpwardsFinished()
    {
        UIManager.Instance.HideWindowByName("ServerSelect");
        UnityEngine.GameObject goLogin = UIManager.Instance.GetWindowGoByName("LoginPrefab");
        if (goLogin != null)
        {
            Login uiLogin = goLogin.GetComponent <Login>();
            if (uiLogin != null)
            {
                uiLogin.TweenDownServerBtn();
                uiLogin.TweenAlphaLoginHint(0.0f, 1f);
            }
        }
        ArkCrossEngine.GfxSystem.PublishGfxEvent("ge_set_current_server", "ui", m_SelectServerId);
        TweenPosition tween = goTweenContainer.GetComponent <TweenPosition>();

        if (null != tween)
        {
            Destroy(tween);
        }
    }
コード例 #45
0
        public override void OnInspectorGUI()
        {
            serObj.Update();

            UnityEngine.GameObject go = ((SpecularLighting)serObj.targetObject).gameObject;
            WaterBase wb = (WaterBase)go.GetComponent(typeof(WaterBase));

            if (!wb.sharedMaterial)
            {
                return;
            }

            if (wb.sharedMaterial.HasProperty("_WorldLightDir"))
            {
                GUILayout.Label("Transform casting specular highlights", EditorStyles.miniBoldLabel);
                EditorGUILayout.PropertyField(specularLight, new GUIContent("Specular light"));

                if (wb.sharedMaterial.HasProperty("_SpecularColor"))
                {
                    WaterEditorUtility.SetMaterialColor(
                        "_SpecularColor",
                        EditorGUILayout.ColorField("Specular",
                                                   WaterEditorUtility.GetMaterialColor("_SpecularColor", wb.sharedMaterial)),
                        wb.sharedMaterial);
                }
                if (wb.sharedMaterial.HasProperty("_Shininess"))
                {
                    WaterEditorUtility.SetMaterialFloat("_Shininess", EditorGUILayout.Slider(
                                                            "Specular power",
                                                            WaterEditorUtility.GetMaterialFloat("_Shininess", wb.sharedMaterial),
                                                            0.0F, 500.0F), wb.sharedMaterial);
                }
            }
            else
            {
                GUILayout.Label("The shader doesn't have the needed _WorldLightDir property.", EditorStyles.miniBoldLabel);
            }

            serObj.ApplyModifiedProperties();
        }
コード例 #46
0
ファイル: FX_Spawner.cs プロジェクト: DireLines/pool-two
    public UnityEngine.GameObject SpawnFX(UnityEngine.GameObject fx, Vector3 position, Vector3 rotation, float vol = -1, Transform parent = null, FXType effectName = FXType.Default)
    {
        if (fx == null)
        {
            return(null);
        }

        if (onesieTracker.ContainsKey(effectName))
        {
            if (onesieTracker[effectName])
            {
                return(null);
            }
        }

        UnityEngine.GameObject spawned_fx = Instantiate(fx, position, Quaternion.identity);
        if (onesieChecker.ContainsKey(effectName) && onesieChecker[effectName])
        {
            onesieTracker[effectName] = spawned_fx;
        }


        if (spawned_fx == null)
        {
            return(null);
        }

        spawned_fx.transform.parent = (parent != null ? parent : holder.transform);

        if (rotation != Vector3.zero)
        {
            spawned_fx.transform.forward = rotation;
        }
        FX_Object fx_obj = spawned_fx.GetComponent <FX_Object>();

        fx_obj.vol        = vol;
        fx_obj.mixerGroup = mixer;

        return(spawned_fx);
    }
コード例 #47
0
ファイル: UISkillSlot.cs プロジェクト: Klanly/UnityClient
    public void SetIconAtlas(int skillId)
    {
        SkillLogicData skillCfg = SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_SKILL, skillId) as SkillLogicData;

        //m_SkillInfo = info;
        if (null != skillCfg)
        {
            UnityEngine.GameObject goAtlas = CrossObjectHelper.TryCastObject <UnityEngine.GameObject>(ResourceSystem.GetSharedResource(skillCfg.ShowAtlasPath));
            if (goAtlas != null)
            {
                UIAtlas atlas = goAtlas.GetComponent <UIAtlas>();
                if (atlas != null && icon != null)
                {
                    icon.atlas = atlas;
                }
            }
            else
            {
                Debug.LogError("!!!Load atlas failed.");
            }
        }
    }
コード例 #48
0
    public void attack(Int32 skillID, Int32 damageType, SceneEntityObject receiver)
    {
        //if(gameEntity != null)
        if (!System.Object.ReferenceEquals(gameEntity, null))
        {
            gameEntity.playAttackAnimation();
        }

        if (receiver == null || receiver.gameEntity == null)
        {
            return;
        }

        //if(particles.inst != null)
        if (!System.Object.ReferenceEquals(particles.inst, null))
        {
            Vector3 v = position;
            UnityEngine.GameObject pobj = null;

            switch (skillID)
            {
            case 7000101:
                pobj = (UnityEngine.GameObject)UnityEngine.GameObject.Instantiate(particles.inst.allpartis[37], gameEntity.gameObject.transform.FindChild("attackPoint").transform.position, rotation);
                SM_moveToEntity sm = pobj.GetComponent <SM_moveToEntity>();
                sm.moveSpeed = 10.0f;
                sm.target    = receiver.gameEntity.gameObject;
                break;

            default:
                break;
            }
            ;

            if (pobj)
            {
                pobj.transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
            }
        }
    }
コード例 #49
0
    public void DisplayDirectory(string directory)
    {
        DirectoryInfo directoryInfo = new DirectoryInfo(directory);
        string        relativePath  = ProjectFileManagerPanel.GetRelativePath(ProjectScene.CurrentProjectPath, directory);

        FileDirectoryLabel.text = (directory == ProjectScene.CurrentProjectPath) ? "[Root]" : relativePath;
        currentPath             = directoryInfo.FullName;
        BackButton.SetActive(NormalizePath(directory) != NormalizePath(ProjectScene.CurrentProjectPath));

        foreach (GameObject fileButton in Buttons)
        {
            Destroy(fileButton);
        }
        Buttons.Clear();

        FileInfo[]      files   = directoryInfo.GetFiles();
        DirectoryInfo[] folders = directoryInfo.GetDirectories();
        foreach (DirectoryInfo folder in folders)
        {
            GameObject newFolderButton = Instantiate(FolderButtonPrefab, ButtonSpawnLocation);
            Buttons.Add(newFolderButton);
            FileBrowserFolderButton buttonController = newFolderButton.GetComponent <FileBrowserFolderButton>();
            buttonController.FileBrowser = this;
            buttonController.FolderPath  = folder.FullName;
            buttonController.Label.text  = folder.Name;
        }

        foreach (FileInfo file in files)
        {
            GameObject newFileButton = Instantiate(FileButtonPrefab, ButtonSpawnLocation);
            Buttons.Add(newFileButton);
            FileBrowserFileButton buttonController = newFileButton.GetComponent <FileBrowserFileButton>();
            buttonController.FrameManager = FrameManager;
            buttonController.Viewer       = FileViewer;
            buttonController.SetupButton(file.FullName);
        }

        NoFileNotice.SetActive(files.Length + folders.Length <= 0);
    }
コード例 #50
0
        public bool CanMerge(UnityEngine.GameObject go)
        {
            bool bret = true;

            MeshFilter lMeshFilter = go.GetComponent <MeshFilter>();

            if (lMeshFilter != null)
            {
                Mesh lMesh = lMeshFilter.sharedMesh;
                UnityEngine.Vector2[] _uvOffset = lMesh.uv;

                for (int uv = 0; uv < _uvOffset.Length; uv++)
                {
                    //Debug.Log("[uv].x = " + _uvOffset[uv].x + " [uv].y = " + _uvOffset[uv].y);
                    if (_uvOffset[uv].x > 1.0f)
                    {
                        bret = false;
                        break;
                    }
                    if (_uvOffset[uv].x < 0.0f)
                    {
                        bret = false;
                        break;
                    }
                    if (_uvOffset[uv].y > 1.0f)
                    {
                        bret = false;
                        break;
                    }
                    if (_uvOffset[uv].y < 0.0f)
                    {
                        bret = false;
                        break;
                    }
                }
                return(bret);
            }
            return(false);
        }
コード例 #51
0
        public void displaySkill(KBEngine.Entity caster, KBEngine.Entity target)
        {
            if (displayType == Skill_DisplayType.SkillDisplay_Event_Bullet)
            {
                UnityEngine.GameObject renderObj = UnityEngine.Object.Instantiate(SkillBox.inst.dictSkillDisplay[skillEffect]) as UnityEngine.GameObject;

                EffectFlying fly = renderObj.GetComponent <EffectFlying>();
                fly.FromPos   = caster.position;
                fly.FromPos.y = 1f;
                fly.ToPos     = target.position;
                fly.ToPos.y   = 1f;

                //fly.Speed = 5.0f;
                //fly.HWRate = 0;
            }
            else if (displayType == Skill_DisplayType.SkillDisplay_Event_Effect)
            {
                Vector3 pos = target.position;
                pos.y = 1f;
                UnityEngine.Object.Instantiate(SkillBox.inst.dictSkillDisplay[skillEffect], pos, Quaternion.identity);
            }
        }
コード例 #52
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player 1")
     {
         inRange     = true;
         enemy       = other.gameObject;
         enemyHealth = enemy.GetComponent <PlayerHealth>();
     }
     if (other.gameObject.tag == "Player 2")
     {
         inRange     = true;
         enemy       = other.gameObject;
         enemyHealth = enemy.GetComponent <PlayerHealth>();
     }
     if (other.gameObject.tag == "Player 3")
     {
         inRange     = true;
         enemy       = other.gameObject;
         enemyHealth = enemy.GetComponent <PlayerHealth>();
     }
     if (other.gameObject.tag == "Player 4")
     {
         inRange     = true;
         enemy       = other.gameObject;
         enemyHealth = enemy.GetComponent <PlayerHealth>();
     }
     if (other.gameObject.tag == "Player 5")
     {
         inRange     = true;
         enemy       = other.gameObject;
         enemyHealth = enemy.GetComponent <PlayerHealth>();
     }
     if (other.gameObject.tag == "Player 6")
     {
         inRange     = true;
         enemy       = other.gameObject;
         enemyHealth = enemy.GetComponent <PlayerHealth>();
     }
 }
コード例 #53
0
        // Applies damage to specified GameObject
        public override void ApplyDamageTo(UnityEngine.GameObject target)
        {
            // if the target object is equal to
            // the source object, return
            if (target == source)
            {
                return;
            }

            // Check the targets tag
            switch (target.tag)
            {
            // if it is the ship
            case "Ship":
                // Get the ship and the shield components
                var ship   = target.GetComponent <Ship>();
                var shield = ship.Shield;

                // if the shield exists
                // Set damage to the CurrentShields
                if (shield != null && shield.CurrentShields >= 0)
                {
                    shield.CurrentShields -= damage;
                }
                // if the shield does not exist
                // Set damage to the ship
                else
                {
                    ship.CurrentHP -= damage;
                }
                break;

            // deafult case
            default:
                break;
            }
            // Destroys object
            Destroy(gameObject);
        }
コード例 #54
0
ファイル: UICenterOnScene.cs プロジェクト: Klanly/UnityClient
    /// <summary>
    /// Center the panel on the specified target.
    /// </summary>

    void CenterOn(UnityEngine.Transform target, UnityEngine.Vector3 panelCenter)
    {
        if (target != null && mScrollView != null && mScrollView.panel != null)
        {
            UnityEngine.Transform panelTrans = mScrollView.panel.cachedTransform;
            mCenteredObject = target.gameObject;
            //通知翻页
            UICurrentChapter currentChapter = mCenteredObject.GetComponent <UICurrentChapter>();
            UISceneSelect    sceneSelect    = NGUITools.FindInParents <UISceneSelect>(this.gameObject);
            if (sceneSelect != null && currentChapter != null)
            {
                sceneSelect.SetCurrentChapter(currentChapter.m_ChapterId);
            }
            // Figure out the difference between the chosen child and the panel's center in local coordinates
            UnityEngine.Vector3 cp          = panelTrans.InverseTransformPoint(target.position);
            UnityEngine.Vector3 cc          = panelTrans.InverseTransformPoint(panelCenter);
            UnityEngine.Vector3 localOffset = cp - cc;

            // Offset shouldn't occur if blocked
            if (!mScrollView.canMoveHorizontally)
            {
                localOffset.x = 0f;
            }
            if (!mScrollView.canMoveVertically)
            {
                localOffset.y = 0f;
            }
            localOffset.z = 0f;

            // Spring the panel to this calculated position
            SpringPanel.Begin(mScrollView.panel.cachedGameObject,
                              panelTrans.localPosition - localOffset, springStrength).onFinished = onFinished;
        }
        else
        {
            mCenteredObject = null;
        }
    }
コード例 #55
0
    private void Awake()
    {
        canvass = go.Find("Canvas");
        for (int i = 0; i < numProperties; i++)
        {
            int j    = i;
            go  obj1 = Instantiate(labelTemplate) as go;
            obj1.SetActive(false);
            obj1.transform.SetParent(scrollContent.transform, false);
            Text text = obj1.GetComponent <Text>();
            text.color = Color.white;
            text.text  = propertiesNames[i];
            labels[i]  = text;

            go obj2 = Instantiate(inputFieldTemplate) as go;
            obj2.SetActive(false);
            obj2.transform.SetParent(scrollContent.transform, false);
            InputField field = obj2.GetComponent <InputField>();
            field.onValueChanged.AddListener(delegate { this.fieldValueChange(j); });
            field.onEndEdit.AddListener(delegate { this.fieldEndEdit(j); });
            inputFields[i] = field;

            go obj3 = Instantiate(sliderTemplate) as go;
            obj3.SetActive(false);
            obj3.transform.SetParent(scrollContent.transform, false);
            Slider s = obj3.GetComponent <Slider>();
            s.onValueChanged.AddListener(delegate { this.sliderValueChange(j); });
            sliders[i] = s;
        }
        go obj4 = Instantiate(deleteButtonTemplate) as go;

        obj4.SetActive(false);
        obj4.transform.SetParent(scrollContent.transform, false);
        Button button = obj4.GetComponent <Button>();

        button.onClick.AddListener(delegate { this.Delete(); });
        deleteButton = obj4;
    }
コード例 #56
0
    //0: width, 1, height
    //anchor1line: 0, anchor2line: 1, anchor1connectline: 2, anchor2connectline: 3

    private void Initiate()
    {
        for (int i = 0; i < 2; i++)
        {
            rtms[i] = new List <rtm>();
        }
        canvas = go.Find("Canvas").GetComponent <rtm>();
        for (int j = 0; j < 2; j++)
        {
            for (int i = 0; i < 4; i++)
            {
                go obj = new go("line", typeof(Image));
                obj.transform.SetParent(this.canvas, false);
                obj.GetComponent <Image>().color = Color.red;
                rtm temp = obj.GetComponent <rtm>();
                temp.anchorMax = temp.anchorMin = new v2(0f, 0f);
                temp.pivot     = new v2(0f, 0.5f);
                temp.gameObject.SetActive(isActive);
                rtms[j].Add(temp);
            }
        }

        //adds the label
        for (int i = 0; i < 2; i++)
        {
            go obj3 = new go("lengthText", typeof(Text));
            obj3.transform.SetParent(this.canvas, false);
            rtm label = obj3.GetComponent <rtm>();
            label.anchorMin = label.anchorMax = new v2(0.5f, 0.5f);
            label.pivot     = new v2(0.5f, 0.5f);
            label.gameObject.SetActive(false);
            rtms[i].Add(label);
            Text t = label.GetComponent <Text>();
            t.color    = new Color(1, 1, 1);
            t.fontSize = 60;
            t.font     = Util.Caladea_Bold;
        }
    }
コード例 #57
0
    void Update()
    {
        if (itemId == -1)
        {
            return;
        }
        //如果快捷栏有物品,则刷新物品状态
        if (inventory == null)
        {
            UnityEngine.GameObject canvas = UnityEngine.GameObject.FindGameObjectWithTag("Canvas");
            inventory = canvas.transform.Find("Panel - Inventory(Clone)").GetComponent <Inventory>();
        }
        if (inventory == null)
        {
            return;
        }
        //物品已使用完或者消失
        UnityEngine.GameObject itemobject = inventory.getItemGameObject(itemId);
        if (itemobject == null)
        {
            this.itemId = -1;
            this.gameObject.SetActive(false);
            return;
        }

        image_icon.sprite = itemobject.GetComponent <ItemOnObject>().item.itemIcon;
        text.rectTransform.localPosition = itemobject.transform.GetChild(1).GetComponent <Text>().transform.localPosition;
        text.enabled = true;
        text.text    = itemobject.transform.GetChild(1).GetComponent <Text>().text;
        if (ConsumeLimitCD.instance.isWaiting())
        {
            image_cool.fillAmount = ConsumeLimitCD.instance.restTime / ConsumeLimitCD.instance.totalTime;
        }
        else
        {
            image_cool.fillAmount = 0;
        }
    }
コード例 #58
0
        IEnumerator FireRocketsRoutine()
        {
            for (int i = 0; i < _misslePositionsLeft.Length; i++)                                                                                                            //for loop to iterate through each missle position
            {
                UnityEngine.GameObject rocketLeft  = Instantiate(_missilePrefab) as UnityEngine.GameObject;                                                                  //instantiate a rocket
                UnityEngine.GameObject rocketRight = Instantiate(_missilePrefab) as UnityEngine.GameObject;                                                                  //instantiate a rocket

                rocketLeft.transform.parent  = _misslePositionsLeft[i].transform;                                                                                            //set the rockets parent to the missle launch position
                rocketRight.transform.parent = _misslePositionsRight[i].transform;                                                                                           //set the rockets parent to the missle launch position

                rocketLeft.transform.localPosition  = Vector3.zero;                                                                                                          //set the rocket position values to zero
                rocketRight.transform.localPosition = Vector3.zero;                                                                                                          //set the rocket position values to zero

                rocketLeft.transform.localEulerAngles  = new Vector3(0, 0, 0);                                                                                               //set the rotation values to be properly aligned with the rockets forward direction
                rocketRight.transform.localEulerAngles = new Vector3(0, 0, 0);                                                                                               //set the rotation values to be properly aligned with the rockets forward direction

                rocketLeft.transform.parent  = null;                                                                                                                         //set the rocket parent to null
                rocketRight.transform.parent = null;                                                                                                                         //set the rocket parent to null

                rocketLeft.GetComponent <GameDevHQ.FileBase.Missle_Launcher_Dual_Turret.Missle.Missle>().AssignMissleRules(_launchSpeed, _power, _fuseDelay, _destroyTime);  //assign missle properties
                rocketRight.GetComponent <GameDevHQ.FileBase.Missle_Launcher_Dual_Turret.Missle.Missle>().AssignMissleRules(_launchSpeed, _power, _fuseDelay, _destroyTime); //assign missle properties

                _misslePositionsLeft[i].SetActive(false);                                                                                                                    //turn off the rocket sitting in the turret to make it look like it fired
                _misslePositionsRight[i].SetActive(false);                                                                                                                   //turn off the rocket sitting in the turret to make it look like it fired

                yield return(new WaitForSeconds(_fireDelay));                                                                                                                //wait for the firedelay
            }

            for (int i = 0; i < _misslePositionsLeft.Length; i++) //itterate through missle positions
            {
                yield return(new WaitForSeconds(_reloadTime));    //wait for reload time

                _misslePositionsLeft[i].SetActive(true);          //enable fake rocket to show ready to fire
                _misslePositionsRight[i].SetActive(true);         //enable fake rocket to show ready to fire
            }

            _launched = false; //set launch bool to false
        }
コード例 #59
0
ファイル: LevelScript.cs プロジェクト: GHChrisSu/uScript
 void SyncEventListeners( )
 {
     if (null == event_UnityEngine_GameObject_Instance_0 || false == m_RegisteredForEvents)
     {
         event_UnityEngine_GameObject_Instance_0 = uScript_MasterComponent.LatestMaster;
         if (null != event_UnityEngine_GameObject_Instance_0)
         {
             {
                 uScript_Update component = event_UnityEngine_GameObject_Instance_0.GetComponent <uScript_Update>();
                 if (null == component)
                 {
                     component = event_UnityEngine_GameObject_Instance_0.AddComponent <uScript_Update>();
                 }
                 if (null != component)
                 {
                     component.OnUpdate      += Instance_OnUpdate_0;
                     component.OnLateUpdate  += Instance_OnLateUpdate_0;
                     component.OnFixedUpdate += Instance_OnFixedUpdate_0;
                 }
             }
         }
     }
 }
コード例 #60
0
 void Update()
 {
     if (hasDes)
     {
         if (Vector3.Distance(transform.position, moveDes.position) < minLen)
         {
             hasDes         = false;
             animator.speed = 1.0f;
             animator.SetFloat("Speed", 0.0f);
             UIGame.GetComponent <UI_Game>().AttackSkill(skillId);
         }
         else
         {
             transform.LookAt(moveDes);
             transform.Translate(Vector3.forward * Time.deltaTime * 5);
             //移动摄像机
             sf.FollowUpdate();
             //播放奔跑动画
             animator.speed = 2.0f;
             animator.SetFloat("Speed", 1.0f);
         }
     }
 }