Inheritance: MonoBehaviour
示例#1
0
    void Shoot()
    {
        flash.Play();
        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);
            Target target = hit.transform.GetComponent <Target> ();
            if (target != null)
            {
                target.TakeDamage(damage);
            }

            if (hit.rigidbody != null)
            {
                hit.rigidbody.AddForce(-hit.normal * impactForce);
            }

            Destroy bottle = hit.transform.GetComponent <Destroy> ();
            if (bottle != null)
            {
                bottle.TakeDamage(damage);
            }

            if (hit.rigidbody != null)
            {
                hit.rigidbody.AddForce(-hit.normal * impactForce);
            }

            GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactGO, 2f);
        }
    }
示例#2
0
        protected override void Serialize(IDictionary <string, object> json)
        {
            var read = Read.ToJson();

            if (Prefix.HasValue())
            {
                json["prefix"] = Prefix;
            }

            if (read.Keys.Any())
            {
                json["read"] = read;
            }

            var update = Update.ToJson();

            if (update.Keys.Any())
            {
                json["update"] = update;
            }

            var create = Create.ToJson();

            if (create.Keys.Any())
            {
                json["create"] = create;
            }

            var destroy = Destroy.ToJson();

            if (destroy.Keys.Any())
            {
                json["destroy"] = destroy;
            }
        }
示例#3
0
    public void DestroyEnemy(EnemyController controller, EnemyView view)
    {
        var model = _controllerModelPairs[controller];

        if (model.Description.CreateNewEnemyAfterDie)
        {
            EnemyController[] controllers;
            EnemyModel[]      models;
            EnemyView[]       views;

            int numPrefab   = Convert.ToInt32(model.Description.TypeEnemy);
            int countChilds = 2;
            _enemySpawnManager.SpawnChildEnemy(model, _enemyPrefabs[numPrefab], countChilds, out controllers, out models, out views);
            if (controllers != null && models != null && views != null)
            {
                for (int i = 0; i < countChilds; i++)
                {
                    controllers[i].Destroy += DestroyEnemy;
                    _controllerModelPairs.Add(controllers[i], models[i]);
                    _viewModelPairs.Add(views[i], models[i]);
                    _enemyModels.Add(models[i]);
                }
            }
        }
        Destroy?.Invoke(model);
        _enemyModels.Remove(model);
        _controllerModelPairs.Remove(controller);
        _viewModelPairs.Remove(view);
        controller.Destroy -= DestroyEnemy;
        controller          = null;
    }
示例#4
0
        public void OwnerCommand(IQ iq, MucRoomMember member)
        {
            Owner owner = iq.Query as Owner;

            // look for destroy
            if (owner != null)
            {
                Destroy destroy = owner.SelectSingleElement(typeof(Destroy)) as Destroy;
                if (destroy != null)
                {
                    DestroyRoom(destroy);
                    return;
                }

                if (!owner.HasChildElements)
                {
                    // Return config
                    owner.AddChild(RoomSettings.GetDataForm(member.Jid));
                }

                Data dataSubmit = (Data)owner.SelectSingleElement(typeof(Data));

                // form config
                if (dataSubmit != null && dataSubmit.Type == XDataFormType.submit)
                {
                    RoomSettings.SubmitForm(dataSubmit);
                    SettingsSave();
                    iq.Query.RemoveAllChildNodes();
                }
            }

            iq.Type = IqType.result;
            iq.SwitchDirection();
        }
 void Start()
 {
     currentHealth = MaxHealth;
     parent        = GetComponentInParent <Destroy>();
     enableAIp     = GetComponentInParent <EnableAIPath>();
     Anim          = GetComponent <Animator>();
 }
示例#6
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "Player")
     {
         destroy = Destroy.Crumbling;
     }
 }
示例#7
0
        protected override void Serialize(System.Collections.Generic.IDictionary <string, object> json)
        {
            if (Filter != DefaultFilter)
            {
                json["filter"] = Filter;
            }

            var messages = this.messages.ToJson();

            if (messages.Any())
            {
                json["messages"] = messages;
            }

            var read = Read.ToJson();

            if (read.Any())
            {
                var transport = new Dictionary <string, object>();
                json["transport"] = transport;

                transport["read"] = read;
                transport["type"] = "imagebrowser-aspnetmvc";

                var thumbnail = Thumbnail.ToJson();
                if (thumbnail.Any())
                {
                    transport["thumbnailUrl"] = thumbnail["url"];
                }

                var upload = Upload.ToJson();
                if (upload.Any())
                {
                    transport["uploadUrl"] = upload["url"];
                }

                var destroy = Destroy.ToJson();
                if (destroy.Any())
                {
                    transport["destroy"] = destroy;
                }

                var create = Create.ToJson();
                if (create.Any())
                {
                    transport["create"] = create;
                }

                var image = Image.Url;
                if (image.HasValue())
                {
                    image = Regex.Replace(image, "(%20)*%7B0(%20)*", "{0", RegexOptions.IgnoreCase);
                    image = Regex.Replace(image, "(%20)*%7D(%20)*", "}", RegexOptions.IgnoreCase);
                    transport["imageUrl"] = image;
                }
            }
        }
示例#8
0
 private void DestroyPlayer()
 {
     Disable();
     Destroy?.Invoke(_playerModel.CurrentScore);
     _playerView.DestroyPlayer();
     _playerViewUI.DestroyPlayer();
     _playerView   = null;
     _playerViewUI = null;
     _playerModel  = null;
 }
示例#9
0
 public void PlayerDamaged()
 {
     PlayerHp -= 1.0f;            // 플레이어 체력 감소
     Debug.Log("Player Damaged"); // 확인용 출력
     if (PlayerHp <= 0)
     {
         Debug.Log("Player die!");     // 플레이어 사망 출력
         Destroy.Log(this.GameObject); // 플레이서 오브젝트 삭제
     }
 }
示例#10
0
 public void Damage(int damage)
 {
     health -= damage;
     if (health <= 0)
     {
         transform.DOScale(Vector3.zero, .2f);
         Destroy destroy = gameObject.AddComponent <Destroy>();
         destroy.destroy = .2f;
         Destroy(this);
     }
 }
示例#11
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        Destroy destroy = other.gameObject.GetComponent <Destroy>();

        destroy.Hit();
        health -= 100;
        if (health <= 0)
        {
            Die();
        }
    }
示例#12
0
        public void Show(Point location)
        {
            if (!Validate(location))
            {
                return;
            }

            Destroy.Disposable(ref timeout);
            Destroy.Disposable(ref tipInfo);

            timeout           = new System.Timers.Timer();
            timeout.AutoReset = false;
            timeout.Enabled   = true;
            timeout.Interval  = 500;
            timeout.Elapsed  += (s, ev) =>
            {
                Destroy.Disposable(ref timeout);
                Destroy.Disposable(ref tipInfo);

                var elem = _selectionResolver.GetElementFromLocation(location);

                if (elem != null)
                {
                    tipInfo = new ToolTip
                    {
                        AutomaticDelay = 0,
                        AutoPopDelay   = 0,
                        InitialDelay   = 0,
                        ReshowDelay    = 0,
                        ToolTipIcon    = ToolTipIcon.Info,
                        UseFading      = true,

                        ToolTipTitle = elem.Id
                    };

                    string text   = GetElementText(elem);
                    Action action = () => tipInfo?.Show(text, _controlToToolTip);

                    if (_controlToToolTip.InvokeRequired)
                    {
                        _controlToToolTip.Invoke(action);
                    }
                    else
                    {
                        action();
                    }

                    lastToolTipLocation = location;
                }
            };

            timeout.Start();
        }
示例#13
0
文件: ModuleBag.cs 项目: e2wugui/zeze
        public override int ProcessDestroyRequest(Destroy rpc)
        {
            Login.Session session    = Login.Session.Get(rpc);
            var           moduleCode = GetBag(session.RoleId.Value).Destory(rpc.Argument.Position);

            if (0 != moduleCode)
            {
                return(ReturnCode((ushort)moduleCode));
            }
            session.SendResponse(rpc);
            return(0);
        }
示例#14
0
    public void Die()
    {
        EnemyManager.enemyManager.SetEnemyDeath(photonView.ViewID, transform.position + new Vector3(0, 1, 0));
        EnemyManager.enemyManager.SetEnemyRagdoll(photonView.ViewID, true);
        thisBody.velocity *= 10;
        Destroy(thisAgent);
        Destroy _DestroyComp = gameObject.AddComponent <Destroy>();

        _DestroyComp.toDestroy      = gameObject;
        _DestroyComp.networkDestroy = true;
        Destroy(this);
    }
示例#15
0
    public void Show(string content, GameObject obj, NpcHeadChatUI.DestroyHandler callback, string combieParam, float time)
    {
        if (obj == null)
        {
            return;
        }

        //if (!npcObjList.Contains(obj))
        //{
        //    npcObjList.Add(obj);

        GameObject clone = (GameObject)GameObject.Instantiate(panelObj_);

        UIPanel rootPane = ApplicationEntry.Instance.uiRoot.GetComponent <UIPanel>();

        clone.transform.parent     = rootPane.transform;
        clone.transform.localScale = Vector3.one;

        Vector3 Objpos = obj.transform.position;

        Objpos = new Vector3(Objpos.x, Objpos.y + obj.transform.GetComponent <BoxCollider>().size.y, Objpos.z);

        Vector3 pos = GlobalInstanceFunction.WorldToUI(Objpos);

        pos = new Vector3(pos.x, pos.y + 80, pos.z);
        clone.transform.localPosition = pos;
        //clone.GetComponent<Destroy> ().CancelInvoke ();
        NpcHeadChatUI nhcUI = clone.GetComponent <NpcHeadChatUI>();

        nhcUI.textLab.text = content;
        nhcUI.SetParam(callback, combieParam);

        Destroy des = clone.AddComponent <Destroy>();

        if (Mathf.Approximately(time, 0f))
        {
            des.lifetime = content.Length * 0.5f;
        }
        else
        {
            des.lifetime = time;
        }

        chatUIObjList.Add(clone);
        for (int i = 0; i < chatUIObjList.Count; ++i)
        {
            if (chatUIObjList[i] == null)
            {
                chatUIObjList.RemoveAt(i);
            }
        }
        //}
    }
示例#16
0
 //子彈的銷毀類別
 void Start()
 {
     DS = GetComponent <Destroy>();
     DS.DestroyGround    = true;
     DS.DestroyPlayer    = true;
     DS.DestroyExplosion = false;
     RD = GetComponent <Rigidbody2D>();
     RD.gravityScale = 0f;
     player          = GameObject.FindGameObjectWithTag("Player");
     Targetdirection = (player.transform.position - gameObject.transform.position).normalized;
     //放在這裡的話 子彈不會追蹤玩家
     //放在update裡子彈會追蹤玩家
 }
示例#17
0
        public void Execute(Entity entity, int index, ref Health health)
        {
            if (rightClick)
            {
                rightClick    = false;
                health.Value -= 1;
            }

            if (health.Value <= 0)
            {
                var destroy = new Destroy();
                CommandBuffer.AddComponent(entity, destroy);
            }
        }
示例#18
0
// DESTRUCTORS ~~~~~~~~~~

// DELEGATES ~~~~~~~~~~

// EVENTS ~~~~~~~~~~

// ENUMS ~~~~~~~~~~

// INTERFACES ~~~~~~~~~~

// PROPERTIES ~~~~~~~~~~

// INDEXERS ~~~~~~~~~~

// METHODS ~~~~~~~~~
/// <summary>
/// Generate a hex map using the provided configuration.
/// </summary>
/// <param name="config">A RootGenConfig scriptable object.</param>
/// <returns>
///     A HexGrid generated according to the config settings.
/// </returns>
    public HexMap GenerateMap(
        RootGenConfig config,
        bool editMode = true
        )
    {
        Destroy.DestroyAll <HexMap>();

        HexMap result = _mapGenerator.GenerateMap(
            config
            );

        HexGridCamera.AttachCamera(result, config);
        return(result);
    }
示例#19
0
    public void Show(Texture tex)
    {
        GameObject clone = (GameObject)GameObject.Instantiate(popTextObj_);

        clone.transform.parent     = ApplicationEntry.Instance.uiRoot.transform;
        clone.transform.localScale = Vector3.one;
        UITexture texture = clone.GetComponentInChildren <UITexture>();

        texture.mainTexture = tex;
        texture.MakePixelPerfect();
        float   lifeTime = clone.GetComponent <UITweener>().duration;
        Destroy des      = clone.AddComponent <Destroy>();

        des.lifetime = lifeTime;
    }
示例#20
0
    // Start is called before the first frame update
    void Start()
    {
        ball = this.gameObject;

        x = Random.Range(-1.3f, 1.33f);
        y = Random.Range(1.4f, 4.3f);
        z = Random.Range(5f, 20f);

        ball.transform.position = new Vector3(x, y, z);

        GetComponent <Renderer>().material.color = colorA.color;

        DestroyScore = GameObject.Find("destry(Clone)");
        destroy      = DestroyScore.GetComponent <Destroy>();
    }
示例#21
0
    public void DestroyAllEnemies()
    {
        _viewModelPairs.Clear();
        var controllerModelArray = _controllerModelPairs.Keys.ToArray();

        for (int i = controllerModelArray.Length - 1; i >= 0; i--)
        {
            var model = _controllerModelPairs[controllerModelArray[i]];
            Destroy?.Invoke(model);
            _enemyModels.Remove(model);
            _controllerModelPairs.Remove(controllerModelArray[i]);
            controllerModelArray[i].Destroy -= DestroyEnemy;
            controllerModelArray[i]          = null;
        }
    }
示例#22
0
    public int bonusAmount = 10; // Value for bonuses.

    // Checks collision between body and bonuses object.
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Destroy destroy = collision.gameObject.GetComponent <Destroy>();

        health = FindObjectOfType <HealthBar>();

        // If bonus was picked then increase health bar.
        if (collision.gameObject.CompareTag("Bonus"))
        {
            //Debug.Log("Picked Up");

            destroy.GetComponent <Destroy>().Kill();
            //health.showHealth();
            health.AddHealth(10);
        }
    } // End of OnTriggerEnter2D method
        public void Show(Position position)
        {
            if (!Validate(position))
            {
                return;
            }

            Destroy.Disposable(ref timeout);
            Destroy.Disposable(ref tipInfo);

            timeout = new System.Timers.Timer
            {
                AutoReset = false,
                Enabled   = true,
                Interval  = 500
            };

            timeout.Elapsed += (s, ev) =>
            {
                Destroy.Disposable(ref timeout);
                Destroy.Disposable(ref tipInfo);

                var elem = _selectionResolver.GetElementFromLocation(position);

                if (elem != null)
                {
                    tipInfo = new ToolTip
                    {
                        AutomaticDelay = 0,
                        AutoPopDelay   = 0,
                        InitialDelay   = 0,
                        ReshowDelay    = 0,
                        ToolTipIcon    = ToolTipIcon.Info,
                        UseFading      = true,

                        ToolTipTitle = elem.Id
                    };

                    string text = GetElementText(elem);
                    _invoker.SafeInvoke(() => tipInfo?.Show(text, _controlToToolTip));

                    lastToolTipLocation = position;
                }
            };

            timeout.Start();
        }
        private async Task RedrawInternalAsync(Func <Gdi.Graphics, LayerSizesPreCalc, Task> drawLayersAction)
        {
            if (!ValidateInputLayer())
            {
                this.ControlCanvas.SetBlank();
            }
            else
            {
                var graphAndImage = this.ControlCanvas.GetGraphics();

                await drawLayersAction(graphAndImage.Graph, graphAndImage.LayerSizes);

                this.ControlCanvas.Image = graphAndImage.Image;

                Destroy.Disposable(ref graphAndImage.Graph);
            }
        }
示例#25
0
    private void OnDestroy()
    {
        Destroy?.Invoke();
        if (_enemy != null)
        {
            _enemy.Kill?.Invoke();
        }

        var units = transform.parent.GetComponentsInChildren <Unit>();

        if (_enemy != null && units.Length == 1)
        {
            if (_enemy.GetComponent <WorkWithUI>() != null)
            {
                _enemy.GetComponent <WorkWithUI>().StopGame();
            }
        }
    }
示例#26
0
    // Use this for initialization
    void Start()
    {
        destroy         = GetComponent <Destroy>();
        destroy.enabled = false;
        //先關閉消滅機制
        destroy.DestroyExplosion = true;
        destroy.DestroyGround    = false;
        destroy.DestroyPlayer    = false;

        CC2D           = GetComponent <CircleCollider2D>();
        CC2D.radius    = 0.25f;
        CC2D.isTrigger = true;
        //碰撞器設初始值
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <EdgeCollider2D>();
        RD     = GetComponent <Rigidbody2D>();
        A      = GetComponent <AI>();
        //取得個變數值
    }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "red")
     {
         PlayerPrefs.SetInt("Score", PlayerPrefs.GetInt("Score") + 1);
         collision.gameObject.tag = "v";
     }
     if (collision.gameObject.tag == "green")
     {
         PlayerPrefs.SetInt("Score", PlayerPrefs.GetInt("Score") - 1);
         collision.gameObject.tag = "v";
     }
     if (PlayerPrefs.GetInt("Score") < 0)
     {
         PlayerPrefs.SetInt("Score", 0);
     }
     script = GetComponent <Destroy>();
     script.Setup(collision.gameObject);
 }
示例#28
0
    public void Show(string content, WarningType type = WarningType.WT_None, bool rightNow = false, string StrColor = "")
    {
        if (showing_ || (GamePlayer.Instance.isInBattle && !rightNow))
        {
            Pkg pkg = new Pkg();
            pkg.content  = content;
            pkg.type     = type;
            pkg.rightNow = rightNow;
            pkg.strColor = StrColor;
            msgQue_.Enqueue(pkg);
            return;
        }
        showing_ = true;
        GameObject clone = (GameObject)GameObject.Instantiate(popTextObj_);

        clone.transform.parent     = ApplicationEntry.Instance.uiRoot.transform;
        clone.transform.localScale = Vector3.one;
        UILabel uLab = clone.GetComponentInChildren <UILabel> ();

        if (!string.IsNullOrEmpty(StrColor))
        {
            //uLab.color = Color.white;
            uLab.text = string.Format("[b][{0}]{1}[-][-]", StrColor, content);;
        }
        else
        {
            uLab.text = string.Format("[b][{0}]{1}[-][-]", popColor[(int)type], content);
        }
        float   lifeTime = clone.GetComponent <UITweener>().duration;
        Destroy des      = clone.AddComponent <Destroy>();

        des.lifetime = lifeTime;
        GlobalInstanceFunction.Instance.Invoke(() =>
        {
            showing_ = false;
            if (msgQue_.Count > 0)
            {
                Pkg p = msgQue_.Dequeue();
                PopText.Instance.Show(p.content, p.type, p.rightNow, p.strColor);
            }
        }, timeGap_);
    }
示例#29
0
        private void DestroyRoom(Destroy destroy)
        {
            Presence offline = new Presence();

            offline.Type = PresenceType.unavailable;
            User user = new User();

            user.Item = new Item(Affiliation.none, Role.none);
            offline.AddChild(user);
            user.AddChild(destroy);
            destroy.Namespace = null;

            foreach (MucRoomMember member in members)
            {
                offline.From = member.Jid;
                member.Send(offline);
            }
            members.Clear();
            mucService.RemoveRoom(this);
        }
示例#30
0
    //构建池
    public TObjectPool(int count, Creat pcreat, Destroy pdestroy, params object[] _vparams)
    {
        if (pcreat == null)
        {
            Debug.LogError("TObjectPool 对象池,委托为空");
            return;
        }
        pCreat   = pcreat;
        pDestroy = pdestroy;
        _params  = _vparams;

        count = Mathf.Clamp(count, 0, 100);
        m_inactitveGameObjects = new Queue <T>();
        for (int i = 0; i < count; ++i)
        {
            T t = pCreat(_params);
            m_inactitveGameObjects.Enqueue(t);
        }
        m_actitveGameObjects = new List <T>();
    }
示例#31
0
 protected override void Given()
 {
     mockRegisteredGraph = MockRepository.GenerateMock<IRegisteredGraph<DummyPersistentObject>>();
     mockStorageWork = MockRepository.GenerateMock<IStorageWork>();
     subject = new Destroy(new InternalId(Guid.NewGuid()), null, mockRegisteredGraph);
 }
示例#32
0
	void Awake()
	{
		destroy = GetComponent<Destroy> ();
	}
示例#33
0
        /// <summary>
        /// </summary>
        /// <param name="room">
        /// </param>
        /// <param name="altVenue">
        /// </param>
        /// <param name="reason">
        /// </param>
        /// <param name="cb">
        /// </param>
        /// <param name="cbArg">
        /// </param>
        public void DestroyRoom(Jid room, Jid altVenue, string reason, IqCB cb, object cbArg)
        {
            /*
             Example 177. Owner Submits Room Destruction Request

            <iq from='[email protected]/desktop'
                id='begone'
                to='*****@*****.**'
                type='set'>
              <query xmlns='http://jabber.org/protocol/muc#owner'>
                <destroy jid='*****@*****.**'>
                  <reason>Macbeth doth come.</reason>
                </destroy>
              </query>
            </iq>
            */
            OwnerIq iq = new OwnerIq();
            iq.Type = IqType.set;
            iq.To = room;

            Destroy destroy = new Destroy();

            if (reason != null)
            {
                destroy.Reason = reason;
            }

            if (altVenue != null)
            {
                destroy.AlternateVenue = altVenue;
            }

            iq.Query.AddChild(destroy);

            if (cb == null)
            {
                m_connection.Send(iq);
            }
            else
            {
                m_connection.IqGrabber.SendIq(iq, cb, cbArg);
            }
        }
示例#34
0
 private void Start()
 {
     this.DestroyEffect = this.GetComponent<Destroy>();
 }